Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.plot with >2 parameters does not work #23

Open
matthiasdiener opened this issue Oct 12, 2020 · 3 comments
Open

.plot with >2 parameters does not work #23

matthiasdiener opened this issue Oct 12, 2020 · 3 comments

Comments

@matthiasdiener
Copy link
Member

$ runalyzer -m summary.dat
Runalyzer running on Python 3.8.5 | packaged by conda-forge | (default, Sep 16 2020, 17:43:11)
[Clang 10.0.1 ]
Copyright (c) Andreas Kloeckner 2008
Run .help to see help for 'magic' commands
>>> .quantities
id | name    | unit | description                 | rank_aggregator
---+---------+------+-----------------------------+-----------------
7  | dt      | s    | Simulation Timestep         | None
9  | fifteen | None | None                        | None
5  | step    | 1    | Timesteps                   | None
2  | t_2step | s    | Step-to-step duration       | None
3  | t_cpu   | s    | Wall time                   | None
4  | t_log   | s    | Time spent updating the log | None
6  | t_sim   | s    | Simulation Time             | None
1  | t_step  | s    | Time step duration          | None
8  | t_vis   | s    | Time spent visualizing      | None
>>> .plot select $step, $t_step, $t_cpu
Traceback (most recent call last):
  File "/Users/mdiener/Work/emirge/logpyle/logpyle/runalyzer.py", line 305, in push
    self.execute_magic(cmdline)
  File "/Users/mdiener/Work/emirge/logpyle/logpyle/runalyzer.py", line 373, in execute_magic
    self.db.plot_cursor(cursor, columnnames)
  File "/Users/mdiener/Work/emirge/logpyle/logpyle/runalyzer.py", line 120, in plot_cursor
    do_plot(x, y, rest)
  File "/Users/mdiener/Work/emirge/logpyle/logpyle/runalyzer.py", line 115, in do_plot
    plot(x, y, hold=True, *args, **my_kwargs)
  File "/Users/mdiener/miniforge3/envs/ceesd/lib/python3.8/site-packages/matplotlib/pyplot.py", line 2840, in plot
    return gca().plot(
  File "/Users/mdiener/miniforge3/envs/ceesd/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 1743, in plot
    lines = [*self._get_lines(*args, data=data, **kwargs)]
  File "/Users/mdiener/miniforge3/envs/ceesd/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 273, in __call__
    yield from self._plot_args(this, kwargs)
  File "/Users/mdiener/miniforge3/envs/ceesd/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 418, in _plot_args
    return [func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)
  File "/Users/mdiener/miniforge3/envs/ceesd/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 418, in <listcomp>
    return [func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)
  File "/Users/mdiener/miniforge3/envs/ceesd/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 312, in _makeline
    seg = mlines.Line2D(x, y, **kw)
  File "/Users/mdiener/miniforge3/envs/ceesd/lib/python3.8/site-packages/matplotlib/lines.py", line 390, in __init__
    self.update(kwargs)
  File "/Users/mdiener/miniforge3/envs/ceesd/lib/python3.8/site-packages/matplotlib/artist.py", line 996, in update
    raise AttributeError(f"{type(self).__name__!r} object "
AttributeError: 'Line2D' object has no property 'hold'
@inducer
Copy link
Collaborator

inducer commented Oct 12, 2020

What type of plot would you expect in this situation?

@matthiasdiener
Copy link
Member Author

No idea, but there seems to be some kind of support for it:

elif len(cursor.description) > 2:
small_legend = kwargs.pop("small_legend", True)
def format_label(kv_pairs):
return " ".join(f"{column}:{value}"
for column, value in kv_pairs)
format_label = kwargs.pop("format_label", format_label)
def do_plot(x, y, row_rest):
my_kwargs = kwargs.copy()
style = PLOT_STYLES[style_idx[0] % len(PLOT_STYLES)]
if auto_style:
my_kwargs.setdefault("dashes", style.dashes)
my_kwargs.setdefault("color", style.color)
my_kwargs.setdefault("label",
format_label(list(zip(
(col[0] for col in cursor.description[2:]),
row_rest))))
plot(x, y, hold=True, *args, **my_kwargs)
style_idx[0] += 1
style_idx = [0]
for x, y, rest in split_cursor(cursor):
do_plot(x, y, rest)
if small_legend:
from matplotlib.font_manager import FontProperties
legend(pad=0.04, prop=FontProperties(size=8), loc="best",
labelsep=0)

Fixing the matplotlib errors results in some ...strange... graphics.

@inducer
Copy link
Collaborator

inducer commented Oct 12, 2020

OIC. I guess it's using the remaining row properties to plot different lines. That means you need to sort by those remaining properties, otherwise you'll understandably get garbage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants