-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # 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?
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.
Yes, observations can't have their style changed now. THis is a design choice, I guess? We could allow the user to input style for obs? Might lead to confusion, however, since I guess the user is pretty happy with a dot for the obs
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 see the color can be changed. But not the marker.
# 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 |
@FrejaTerpPetersen What is the status on this PR? |
@ecomodeller I think it is ready for merge, unless you have further comments. I updated according to Jespers comments:
@ecomodeller, @jsmariegaard - do you want to review before merging? |
Yes, either @ecomodeller or I will merge after review. Thanks |
if isinstance(arg, str): | ||
# If arg is str, convert to list (for looping) | ||
arg = [arg] | ||
if arg is not None and len(arg) < n_mod: |
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.
This doesn't account for the case where the user passes more arguments than n_mod. This should not be silently ignored.
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