Note
Go to the end to download the full example code.
Date Axis for Bar Charts#
Axes in general work the same way independent of what type of mode a series is.
For example a bar chart can be used with a date type x-axis. Options like tick_interal or tick_format are still respected.
/home/runner/work/visualization_toolkit/visualization_toolkit/visualization_toolkit/helpers/plotly/charts/core/chart.py:651: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
import pandas as pd
from datetime import date
from dateutil.relativedelta import relativedelta
from visualization_toolkit.helpers.plotly import chart, axis, series
fig = chart(
pdf,
x_axis=axis(
column_name="day",
axis_type="date",
label="Week Ending",
tick_interval=relativedelta(days=14),
axis_min=date(2024, 6, 30),
axis_max=date(2024, 10, 20),
),
chart_series=[
series(
column_name="abnb_gbv_share",
label="ABNB GBV Share",
color="dark-blue",
mode="bar",
),
],
y1_axis=axis(
axis_type="percent",
axis_min=0,
axis_max=1,
tick_format="0.0%",
),
)
fig
Total running time of the script: (0 minutes 0.023 seconds)