atmospy.calendarplot#
- atmospy.calendarplot(data, x, y, freq='day', agg='mean', vmin=None, vmax=None, cmap='crest', ax=None, linecolor='white', linewidths=0, cbar=True, cbar_kws=None, xlabel=None, ylabel=None, title=None, units='', height=2, aspect=5.0, faceted=False, **kwargs)#
Visualize data as a heatmap on a monthly or annual basis.
Calendar plots can be a useful way to visualize trends in data over longer periods of time. This function is quite generic and allows you to visualize data either by month (where the x-axis is day of month and y-axis is hour of day) or year (where x-axis is the week of the year and y-axis is the day of the week). Configure the plot to aggregrate the data any way you choose (e.g., sum, mean, max).
Currently, you can only plot a single month or single year at a time depending on configuration. To facet these, please set up a Seaborn FacetGrid and call the calendarplot separately.
This function is heavily influenced by the calplot python library.
- Parameters:
- data
pandas.DataFrame
Tabular data as a pandas DataFrame.
- xkey in
data
Variable that corresponds to the timestamp column in
data
.- ykey in
data
Variable that corresponds to the variable you would like to group and plot.
- freqstr, optional
The frequency by which to average (one of [
hour
,day
]), by default “day”- aggstr, optional
The function to aggregate by, by default “mean”
- vminfloat, optional
The minimum value to color by, by default None
- vmaxfloat, optional
The maximum value to color by, by default None
- cmapstr, optional
The name of the colormap, by default “crest”
- axaxes, optional
A matplotlib axes object, by default None
- linecolorstr, optional
The color of the inner lines, by default “white”
- linewidthsint, optional
The width of the inner lines, by default 0
- cbarbool, optional
If true, add a colorbar, by default True
- cbar_kwsdict, optional
A dictionary of kwargs to send along to the colorbar, by default None
- xlabelstr, optional
The x-axis label, by default None
- ylabelstr, optional
The y-axis label, by default None
- titlestr, optional
The figure title, by default None
- unitsstr, optional
The units of the plotted item for labeling purposes only, by default “”
- heightint, optional
The figure height in inches, by default 2
- aspectfloat, optional
The aspect ratio of the figure, by default 5.0
- facetedbool optional
Set to
True
if combining with a FacetGrid, optional
- data
- Returns:
Examples
Plot a simple heatmap for the entire year.
>>> df = atmospy.load_dataset("us-bc") >>> atmospy.calendarplot(df, x="Timestamp GMT", y="Sample Measurement")