-
Notifications
You must be signed in to change notification settings - Fork 9
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
Timeseries plot style #465
base: main
Are you sure you want to change the base?
Conversation
@FrejaTerpPetersen for the benefit of the interested reader... could you please include some sample code and screenshots of the new functionality in this description above. Visuals are easy to grasp, when browsing around. |
Sure thing - I updated the description |
else: | ||
if color is None: | ||
color = MOD_COLORS | ||
mod.plot(ax=ax, color=color[j]) | ||
|
||
ax.scatter( | ||
cmp.time, | ||
cmp.data[cmp._obs_name].values, | ||
marker=".", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style does not affect the observations, is this the intended behaviour?
if backend == "matplotlib": | ||
fig, ax = _get_fig_ax(ax, figsize) | ||
for j in range(cmp.n_models): | ||
key = cmp.mod_names[j] | ||
mod = cmp.raw_mod_data[key]._values_as_series | ||
mod.plot(ax=ax, color=MOD_COLORS[j]) | ||
if style is not None: | ||
mod.plot(ax=ax, style=style[j]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to add a check (outside the loop) that the length of the style list is the same as the number of models (or models+1 obs, see comment below).
# Color for observations: | ||
obs_color = cmp.data[cmp._obs_name].attrs["color"] | ||
|
||
# if color is None and style is None: # Use default values for colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
I would like to see a few changes:
- please change _check_kwarg_and_convert_to_list to only check for either style or color and rename to _check_arg_length_match_nmodels(arg, arg_name, n_mod) or to something with _parse (as it returns the same argument again)
- move the function out of _misc.py and to top of _comparer_plotter.py (it is only used in this module)
- I think we should allow either lengths n_mod and n_mod+1 only (i.e. also issue exception if length is too long)
- It seems that the color and style args work a little different if you want to change the obs apperance also. Is it correct that you cannot change the style of the observation.
- I guess the style and color arguments only applied to matplotlib backend and not plotly. If that is the case - it should be clear in the docstring. Better: add it to plotly backend also.
- currently all kwargs are accepted, e.g.
cmp.plot.timeseries(assdsddsdas="Reds")
does not give me an error message. It should. It is not strictly part of this PR, but as this function is now "open", we should fix it. - I have added a short notebook with examples - maybe you could expand it a little bit?
closes #463 |
An update to the comparer plotter such that it takes a style and a color input. I wanted to also allow for color input, since this is actually the main reason why I started the issue #463: I want to use my own colors to match my other plots. The style input is just a bonus from my point of view :)
Design decisions:
Example 1: giving a color input
This code yields the following plot:
Example 2: also specifying the color of the observation points
Above, the default color of the observations is black. If we want them to be e.g. green instead, we pass it as the first color.
This yields the following plot:
Example 3: giving a style input
We can also pass a style input instead