Passing matplotlib arguments to plot.timeseries()
I would like to be able to choose colors and linestyles of the timeseries plot in modelskil. I use the following code:
cc2["Drogden"] is a modelskill comparer.
Where I essentially would like to do something along the lines of:
(cc2["Drogden"].sel(start="10-05-1997",end="10-17-1997")).plot.timeseries(ax=ax, col=pal)
where pal is a list holding the matplotlib color codes. Similarly for linestyles.
I suppose we could forward the formatting to pandas https://pandas.pydata.org/pandas-docs/stable/user_guide/visualization.html#general-plot-style-arguments
I suppose we could forward the formatting to pandas https://pandas.pydata.org/pandas-docs/stable/user_guide/visualization.html#general-plot-style-arguments
Can you alter individual line styles and colors in this way?
Alternatively, I still have a dream of each model has it's own color attribute (actually it already has but it is just not used). See also top of the backlog list: https://github.com/orgs/DHI/projects/32 this does not include the linestyle though...
import pandas as pd
data = {'Model A': [10, 20, 30, 40, 50],
'Model B': [5, 10, 15, 20, 25],
'Observations': [1, 2, 3, 4, 5]}
df = pd.DataFrame(data)
df.plot(style=['-', 'r-', 'g-o'])
@FrejaTerpPetersen would you like to give this a try. You can open a PR and we can help you :-)
I would suggest this API:
cc.plot.timeseries(style=['-', 'r-', 'g-o'])
as it is consistent with the pandas API. You would need to add the new argument to https://github.com/DHI/modelskill/blob/22f0fca1f72f36c4d00f1ba83800064c6de19547/modelskill/comparison/_comparer_plotter.py#L57 - you will need to add a test to in https://github.com/DHI/modelskill/blob/main/tests/test_timeseries_plot.py that uses the new argument.
I guess a main design decision here is to decide on the allowed length of the style-list (should it be number-of-models, numer-of-models-plus-obs, or any of the two)... But that we can discuss in the PR.
I'll try :)