Note
Go to the end to download the full example code.
Chart Floating Annotations#
Annotations be placed on a chart that is positioned on both axes. This can be useful to draw attentiong to specific point(s).
The annotation must specify the
valueas a tuple of x,y locationsEach value of the tuple should match the data type of their respective axis
In this case, the annotation tuple uses a date for the x-axis position and a float for the y-axis position
from datetime import date
import pandas as pd
from dateutil.relativedelta import relativedelta
from visualization_toolkit.helpers.plotly import chart, axis, series, annotation
fig = chart(
pdf,
x_axis=axis(
column_name="day",
axis_type="date",
label="Week Ending",
tick_interval=relativedelta(days=7 * 6),
),
chart_series=[
series(
column_name="abnb_gbv_share",
label="ABNB GBV Share",
color="dark-blue",
),
series(
column_name="vrbo_gbv_share",
label="VRBO GBV Share",
color="red",
),
],
y1_axis=axis(
axis_type="percent",
axis_min=0,
axis_max=1,
tick_format="0.0%",
),
annotations=[
annotation(
text="2023Q1 VRBO <br /> GBV Share",
value=(date(2024, 3, 13), 0.25),
position="top right",
),
annotation(
text="2023Q3 VRBO <br /> GBV Share",
value=(date(2024, 9, 30), 0.29),
position="top right",
),
],
)
fig
Total running time of the script: (0 minutes 0.021 seconds)