<jupyter_start><jupyter_text>URL: http://bokeh.pydata.org/en/latest/docs/gallery/stocks.htmlMost examples work across multiple plotting backends, this example is also available for:* [Bokeh - stocks example](../bokeh/stocks_example.ipynb)<jupyter_code>import numpy as np
import pandas as pd
import holoviews as hv
hv.extension('matplotlib')
%output fig='svg' dpi=120<jupyter_output><empty_output><jupyter_text>Defining the data<jupyter_code>from holoviews.operation.timeseries import rolling
from bokeh.sampledata.stocks import AAPL, GOOG, IBM, MSFT

def get_curve(data, label=''):
    df = pd.DataFrame(data)
    df['date'] = df.date.astype(np.datetime64)
    return hv.Curve(df, label=label, kdims=[('date', 'Date')],
                    vdims=[('adj_close', 'Price')])

hv.Dimension.type_formatters[np.datetime64] = '%Y'

aapl = get_curve(AAPL, label='AAPL')
goog = get_curve(GOOG, label='GOOG')
ibm  = get_curve(IBM, label='IBM')
msft = get_curve(MSFT, label='MSFT')

avg_curve = rolling(aapl, rolling_window=30).relabel('Average')
avg_scatter = hv.Scatter(avg_curve, label='close')

color_cycle = hv.Cycle(values=['#A6CEE3', '#B2DF8A','#33A02C', '#FB9A99'])<jupyter_output><empty_output><jupyter_text>Plot<jupyter_code>plot_opts = dict(aspect=1, fig_size=200, legend_position='top_left')

hv.Store.options(backend='matplotlib').Curve = hv.Options('style', color=color_cycle)

scatter_style = dict(alpha=0.2, size=4, color='darkgrey')
curve_style = dict(color='navy')

(aapl * goog * ibm * msft).opts(plot=plot_opts) +\
(avg_scatter(style=scatter_style) * avg_curve(style=curve_style)).opts(plot=plot_opts)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15853658536585366, 'fraction_numerical': 0.016463414634146342, 'mean_word_length': 7.164179104477612, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '18933', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 663, 'n_tokens_neox': 630, 'n_words': 100, 'path': 'examples/gallery/demos/matplotlib/stocks_example.ipynb', 'repo_name': 'stonebig/holoviews', 'size': '1640'}