hvPlot.area#
- hvPlot.area(x=None, y=None, y2=None, stacked=True, **kwds)[source]#
The area plot can be used to color the area under a line or to color the space between two lines.
Reference: https://hvplot.holoviz.org/ref/api/manual/hvplot.hvPlot.area.html
Plotting options: https://hvplot.holoviz.org/ref/plotting_options/index.html
- Parameters:
- xstring, optional
Field name(s) to draw x-positions from. If not specified, the index is used. Can refer to continuous and categorical data.
- ystring, optional
Field name to draw the first y-position from
- y2string, optional
Field name to draw the second y-position from
- stackedboolean, optional
Whether to stack multiple areas. Default is True.
- **kwdsoptional
Additional keywords arguments are documented in Plotting Options. Run
hvplot.help('area')
for the full method documentation.
- Returns:
holoviews.element.Area
/ Panel objectYou can print the object to study its composition and run:
import holoviews as hv hv.help(the_holoviews_object)
to learn more about its parameters and options.
References
Bokeh: https://docs.bokeh.org/en/latest/docs/user_guide/basic/areas.html#directed-areas
HoloViews: https://holoviews.org/reference/elements/matplotlib/Area.html
Pandas: https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.plot.area.html
Matplotlib: https://matplotlib.org/stable/gallery/lines_bars_and_markers/fill_between_demo.html
Backend-specific styling options#
alpha, color, fill_alpha, fill_color, hover_alpha, hover_color, hover_fill_alpha, hover_fill_color, hover_line_alpha, hover_line_cap, hover_line_color, hover_line_dash, hover_line_dash_offset, hover_line_join, hover_line_width, line_alpha, line_cap, line_color, line_dash, line_dash_offset, line_join, line_width, muted, muted_alpha, muted_color, muted_fill_alpha, muted_fill_color, muted_line_alpha, muted_line_cap, muted_line_color, muted_line_dash, muted_line_dash_offset, muted_line_join, muted_line_width, nonselection_alpha, nonselection_color, nonselection_fill_alpha, nonselection_fill_color, nonselection_line_alpha, nonselection_line_cap, nonselection_line_color, nonselection_line_dash, nonselection_line_dash_offset, nonselection_line_join, nonselection_line_width, selection_alpha, selection_color, selection_fill_alpha, selection_fill_color, selection_line_alpha, selection_line_cap, selection_line_color, selection_line_dash, selection_line_dash_offset, selection_line_join, selection_line_width, visible
alpha, c, capstyle, color, ec, ecolor, edgecolor, facecolor, fc, fill, hatch, interpolate, joinstyle, linestyle, linewidth, lw, step
Examples#
Simple area plot#
import hvplot.pandas # noqa
import pandas as pd
df = pd.DataFrame({"x": [0, 1, 2, 3], "y": [0, 1, 4, 9]})
df.hvplot.area(x="x", y="y")
Single area for a timeseries#
This example displays the area under Apple’s stock adjusted closing price over time.
import hvplot.pandas # noqa
df = hvplot.sampledata.apple_stocks("pandas")
df.hvplot.area(x="date", y="adj_close", color="#1e85f7", alpha=0.5, height=300)
Stacked area for multiple series#
This example shows stacked areas for several tech company stock prices. stack
is True
by default.
import hvplot.pandas # noqa
df = hvplot.sampledata.stocks("pandas")
df.hvplot.area(x="date", y=["Apple", "Amazon", "Netflix"], alpha=0.4, ylim=(1, None))
Non-stacked area for multiple series#
This example shows non-stacked areas for several tech company stock prices, by setting stacked
to False
. Note that alpha
is automatically set to 0.5
in this case.
import hvplot.pandas # noqa
df = hvplot.sampledata.stocks("pandas")
df.hvplot.area(x="date", y=["Apple", "Amazon", "Netflix"], ylim=(1, None), stacked=False)
Area between two lines using y and y2#
This example fills the space between the low and high prices of Apple’s stock, by setting y
(low) and y2
(high).
import hvplot.pandas # noqa
import pandas as pd
df = hvplot.sampledata.apple_stocks("pandas")
df.hvplot.area(
x="date",
y="low",
y2="high",
ylabel="Prices",
xlim=(pd.Timestamp("2023-03-01"), pd.Timestamp("2023-11-01")),
ylim=(140, 200),
)