from am4894pd.utils import df_dummy_ts # used to generate some dummy data
from am4894plots.plots import plot_lines, plot_lines_grid
from am4894plots.lines.bokeh import plot_lines as plot_lines_bokeh
from am4894plots.lines.bokeh import plot_lines_grid as plot_lines_grid_bk
# generate some dummy time series data
df = df_dummy_ts(n_cols=10, freq='1min')
print(df.shape)
display(df.head())
(1342, 10)
col0 | col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8 | col9 | |
---|---|---|---|---|---|---|---|---|---|---|
time | ||||||||||
2019-01-01 01:39:00 | -0.037434 | 0.117573 | 0.189879 | 0.002616 | -0.079472 | 0.115318 | -0.048063 | -0.002904 | -0.011602 | 0.005502 |
2019-01-01 01:40:00 | -0.032349 | 0.106346 | 0.199563 | 0.002649 | -0.089620 | 0.095387 | -0.054562 | -0.016973 | -0.021907 | 0.026605 |
2019-01-01 01:41:00 | -0.065608 | 0.087076 | 0.189810 | 0.001083 | -0.069259 | 0.075435 | -0.037395 | -0.035694 | -0.063104 | 0.025187 |
2019-01-01 01:42:00 | -0.061601 | 0.067645 | 0.183253 | 0.006044 | -0.073584 | 0.070739 | -0.032002 | -0.039580 | -0.048021 | 0.017649 |
2019-01-01 01:43:00 | -0.053738 | 0.050435 | 0.167004 | 0.022624 | -0.088897 | 0.059226 | -0.037980 | -0.055101 | -0.031053 | 0.015228 |
# make shaded region
shade_regions = [
(df.index[-300:].min(), df.index[-101], 'lightblue'),
(df.index[-100:].min(), df.index.max(), 'yellow')
]
print(shade_regions)
[(Timestamp('2019-01-01 19:01:00'), Timestamp('2019-01-01 22:20:00'), 'lightblue'), (Timestamp('2019-01-01 22:21:00'), Timestamp('2019-01-02 00:00:00'), 'yellow')]
subplot_titles = ['col0 & col1', 'col2', 'col3']
plot_cols = [['col0','col1'], 'col2', 'col3']
# plot each time series on single plot as a line
plot_lines_grid(
df, plot_cols, subplot_titles=subplot_titles, return_p=False, show_p=False, out_path='example_plots/grid_with_stacked.html', h_each=200,
w=1200, legend=False, yaxes_visible=False, shade_regions=shade_regions, text_position='bottom right',
xaxes_visible=False
)