import hvplot.pandas # noqa
area
can be used to color the area under a line or to color the space between two lines.
from bokeh.sampledata.degrees import data
data.tail()
First we'll look at a single curve, where we are enforcing the y axis must be between 0 and 100 and we set the background color.
data.hvplot.area(x='Year', y='Computer Science', label='% of Computer Science Degrees Earned by Women',
ylim=(0, 100), width=500, height=400).opts(bgcolor='goldenrod')
import pandas as pd
from bokeh.sampledata.stocks import MSFT
df = pd.DataFrame(MSFT)
df['date'] = pd.to_datetime(df.date)
df.head()
To color the area between two curves, include both a y
and a y2
.
df[df.date.dt.year == 2000].hvplot.area(x='date', y='low', y2='high')
When multiple y values are passed, they are stacked by default.
df.hvplot.area(x='date', y=['open', 'close'])
Area plots can also be unstacked:
df.hvplot.area(x='date', y=['open', 'close'], stacked=False,
groupby='date.year', legend='bottom_right', width=500)