{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(1342, 10)\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
col0col1col2col3col4col5col6col7col8col9
time
2019-01-01 01:39:00-0.0374340.1175730.1898790.002616-0.0794720.115318-0.048063-0.002904-0.0116020.005502
2019-01-01 01:40:00-0.0323490.1063460.1995630.002649-0.0896200.095387-0.054562-0.016973-0.0219070.026605
2019-01-01 01:41:00-0.0656080.0870760.1898100.001083-0.0692590.075435-0.037395-0.035694-0.0631040.025187
2019-01-01 01:42:00-0.0616010.0676450.1832530.006044-0.0735840.070739-0.032002-0.039580-0.0480210.017649
2019-01-01 01:43:00-0.0537380.0504350.1670040.022624-0.0888970.059226-0.037980-0.055101-0.0310530.015228
\n", "
" ], "text/plain": [ " col0 col1 col2 col3 col4 \\\n", "time \n", "2019-01-01 01:39:00 -0.037434 0.117573 0.189879 0.002616 -0.079472 \n", "2019-01-01 01:40:00 -0.032349 0.106346 0.199563 0.002649 -0.089620 \n", "2019-01-01 01:41:00 -0.065608 0.087076 0.189810 0.001083 -0.069259 \n", "2019-01-01 01:42:00 -0.061601 0.067645 0.183253 0.006044 -0.073584 \n", "2019-01-01 01:43:00 -0.053738 0.050435 0.167004 0.022624 -0.088897 \n", "\n", " col5 col6 col7 col8 col9 \n", "time \n", "2019-01-01 01:39:00 0.115318 -0.048063 -0.002904 -0.011602 0.005502 \n", "2019-01-01 01:40:00 0.095387 -0.054562 -0.016973 -0.021907 0.026605 \n", "2019-01-01 01:41:00 0.075435 -0.037395 -0.035694 -0.063104 0.025187 \n", "2019-01-01 01:42:00 0.070739 -0.032002 -0.039580 -0.048021 0.017649 \n", "2019-01-01 01:43:00 0.059226 -0.037980 -0.055101 -0.031053 0.015228 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from am4894pd.utils import df_dummy_ts # used to generate some dummy data\n", "from am4894plots.plots import plot_lines, plot_lines_grid\n", "from am4894plots.lines.bokeh import plot_lines as plot_lines_bokeh\n", "from am4894plots.lines.bokeh import plot_lines_grid as plot_lines_grid_bk\n", "\n", "# generate some dummy time series data\n", "df = df_dummy_ts(n_cols=10, freq='1min')\n", "print(df.shape)\n", "display(df.head())" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[(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')]\n" ] } ], "source": [ "# make shaded region\n", "shade_regions = [\n", " (df.index[-300:].min(), df.index[-101], 'lightblue'),\n", " (df.index[-100:].min(), df.index.max(), 'yellow')\n", "]\n", "print(shade_regions)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "subplot_titles = ['col0 & col1', 'col2', 'col3']" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "plot_cols = [['col0','col1'], 'col2', 'col3']" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# plot each time series on single plot as a line\n", "plot_lines_grid(\n", " df, plot_cols, subplot_titles=subplot_titles, return_p=False, show_p=False, out_path='example_plots/grid_with_stacked.html', h_each=200, \n", " w=1200, legend=False, yaxes_visible=False, shade_regions=shade_regions, text_position='bottom right', \n", " xaxes_visible=False\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.1" } }, "nbformat": 4, "nbformat_minor": 4 }