modelskill icon indicating copy to clipboard operation
modelskill copied to clipboard

First attempt at ComparerCollection.plot.timeseries

Open ecomodeller opened this issue 1 year ago • 1 comments

ComparerCollection lacks a simple way to plot all timeseries in one go.

This is some stumbling steps of utilizing plt.subplots, but it is far from perfect.

Once this is polished, it will also be relevant to be able to subset the collection in a terse way, e.g. with wildcards.

image

ecomodeller avatar Jan 30 '24 12:01 ecomodeller

Python + R it makes it possible to get good plots with readable syntax.

image

import modelskill as ms
...
cc = ms.ComparerCollection(cmps)
ldf = cc._to_long_dataframe().reset_index()
sel_station <- py$ldf |>
    select(observation) |>
    distinct() |>
    slice(1:3) |>
    pull(observation)

py$ldf |>
    filter(observation %in% sel_station) |>
    ggplot(aes(time, obs_val)) +
     geom_point(size=1, shape="+") + 
     geom_line(aes(time, mod_val, color=model)) +    
     facet_grid(vars(observation), scales="free_y") + 
     labs(x="Time", y="Discharge [m3/s]") +
     theme_bw()

Could I do the same with plotnine in Python 🤔

ecomodeller avatar Jan 30 '24 20:01 ecomodeller