Core
plot_blank_calendar(day_labeler=DayLabeler(), time_labeler=TimeLabeler(), display_settings=None, ax=None, grid_lines=GridLines(), monday_start=True)
Create a blank calendar with no data
Parameters:
Name | Type | Description | Default |
---|---|---|---|
day_labeler
|
DayLabeler
|
instance in order to configure the day labels |
DayLabeler()
|
time_labeler
|
TimeLabeler
|
instance in order to configure the time labels |
TimeLabeler()
|
display_settings
|
DisplaySettings | None
|
override of the display settings in the calendar |
None
|
ax
|
Axes | None
|
Optional axes to plot on |
None
|
grid_lines
|
GridLines
|
GridLines instance |
GridLines()
|
monday_start
|
bool
|
whether to start the week on Monday or Sunday |
True
|
Returns:
Type | Description |
---|---|
Axes
|
Modified matplotlib axis |
Source code in latent_calendar/plot/core/calendar.py
plot_calendar(calendar_iter, *, day_labeler=DayLabeler(), time_labeler=TimeLabeler(), display_settings=None, cmap=None, alpha=None, ax=None, grid_lines=GridLines(), monday_start=True)
Plot a calendar from generator of values.
This can plot both numpy matrix and DataFrame values as long as the iterable fits CALENDAR_ITERATION definition
Parameters:
Name | Type | Description | Default |
---|---|---|---|
calendar_iter
|
CALENDAR_ITERATION
|
CALENDAR_ITERATION |
required |
day_labeler
|
DayLabeler
|
instance in order to configure the day labels |
DayLabeler()
|
time_labeler
|
TimeLabeler
|
instance in order to configure the time labels |
TimeLabeler()
|
display_settings
|
DisplaySettings | None
|
override of the display settings in the calendar |
None
|
cmap
|
CMAP | None
|
function that maps floats to string colors |
None
|
ax
|
Axes | None
|
Optional axes to plot on |
None
|
grid_lines
|
GridLines
|
GridLines instance |
GridLines()
|
monday_start
|
bool
|
whether to start the week on Monday or Sunday |
True
|
Returns:
Type | Description |
---|---|
Axes
|
Modified matplotlib axis |
Source code in latent_calendar/plot/core/calendar.py
plot_calendar_by_row(df, max_cols=3, title_func=None, day_labeler=None, time_labeler=None, cmaps=None, grid_lines=GridLines(), monday_start=True)
Iterate a DataFrame by row and plot calendar events.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
wide DataFrame where each column is the vocabulary |
required |
max_cols
|
int
|
max number of columns in the created grid. |
3
|
title_func
|
TITLE_FUNC | None
|
function to make the title from DataFrame index and DataFrame row, default like '2020-01-01 n_trip(s) = 10' |
None
|
day_labeler
|
DayLabeler | None
|
base day_labeler |
None
|
time_labeler
|
TimeLabeler | None
|
base day_labeler |
None
|
cmaps
|
CMAP | ColorMap | CMAP_GENERATOR | None
|
Colormapping function(s) to use for each row |
None
|
grid_lines
|
GridLines
|
GridLines instance |
GridLines()
|
monday_start
|
bool
|
whether to start the week on Monday or Sunday |
True
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in latent_calendar/plot/core/calendar.py
plot_dataframe_as_calendar(df, config, *, day_labeler=DayLabeler(), time_labeler=TimeLabeler(), grid_lines=GridLines(), cmap=None, alpha=None, ax=None, monday_start=True)
Simple Wrapper about plot_calendar in order to plot DataFrame in various formats
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame in format with columns in config instance |
required |
config
|
DataFrameConfig
|
DataFrameConfig |
required |
day_labeler
|
DayLabeler
|
instance in order to configure the day labels |
DayLabeler()
|
time_labeler
|
TimeLabeler
|
instance in order to configure the time labels |
TimeLabeler()
|
grid_lines
|
GridLines
|
GridLines instance |
GridLines()
|
cmap
|
CMAP | None
|
function that maps floats to string colors |
None
|
alpha
|
float | None
|
alpha level of each rectangle |
None
|
ax
|
Axes | None
|
optional axis to plot on |
None
|
monday_start
|
bool
|
whether to start the week on Monday or Sunday |
True
|
Returns:
Type | Description |
---|---|
Axes
|
new or modified axes |
Source code in latent_calendar/plot/core/calendar.py
plot_dataframe_grid_across_column(df, grid_col, config=None, max_cols=3, *, alpha=None, monday_start=True, day_labeler=DayLabeler(), time_labeler=TimeLabeler(), grid_lines=GridLines())
Plot the long DataFrame in a grid by some different column.
Continuous version of the plot_calendar_by_row
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame to plot. Requires all the columns in config |
required |
grid_col
|
str
|
column name of DataFrame to plot across |
required |
config
|
DataFrameConfig | None
|
DataFrameConfig instance of the column mapping. Default IterConfig |
None
|
max_cols
|
int
|
max number of columns in the grid |
3
|
alpha
|
float | None
|
alpha of each calendar event |
None
|
monday_start
|
bool
|
whether to start the week on Monday or Sunday |
True
|
Source code in latent_calendar/plot/core/calendar.py
plot_series_as_calendar(series, *, grid_lines=GridLines(), day_labeler=DayLabeler(), time_labeler=TimeLabeler(), cmap=None, alpha=None, ax=None, monday_start=True)
Simple Wrapper about plot_calendar in order to plot Series in various formats
Parameters:
Name | Type | Description | Default |
---|---|---|---|
series
|
Series
|
Series in format with index as datetime and values as float |
required |
grid_lines
|
GridLines
|
GridLines instance |
GridLines()
|
day_labeler
|
DayLabeler
|
instance in order to configure the day labels |
DayLabeler()
|
time_labeler
|
TimeLabeler
|
instance in order to configure the time labels |
TimeLabeler()
|
cmap
|
CMAP | None
|
function that maps floats to string colors |
None
|
alpha
|
float | None
|
alpha level of each rectangle |
None
|
ax
|
Axes | None
|
optional axis to plot on |
None
|
monday_start
|
bool
|
whether to start the week on Monday or Sunday |
True
|
Returns:
Type | Description |
---|---|
Axes
|
new or modified axes |
Source code in latent_calendar/plot/core/calendar.py
Plots including a model.
plot_component_distribution(X_latent, model, ax)
Third profile plot.
Source code in latent_calendar/plot/core/model.py
plot_distribution(X_probs, ax, display_y_axis=True, divergent=True, day_labeler=DayLabeler(), time_labeler=TimeLabeler())
Second plot of the profile calendar probability distribution.
Source code in latent_calendar/plot/core/model.py
plot_model_components(model, max_cols=5, divergent=True, components=None, day_labeler=DayLabeler(), time_labeler=TimeLabeler())
Helper function to create plot of all the components of the LatentCalendar instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
LatentCalendar
|
LatentCalendar instance |
required |
max_cols
|
int
|
maximum number of columns in the grid of calendar components. |
5
|
divergent
|
bool
|
what data to plot |
True
|
components
|
Iterable[int] | None
|
Specific subset of components to plot. Default is all |
None
|
day_labeler
|
DayLabeler
|
DayLabeler instance |
DayLabeler()
|
time_labeler
|
TimeLabeler
|
TimeLabeler instance |
TimeLabeler()
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in latent_calendar/plot/core/model.py
plot_model_predictions(X_to_predict, X_holdout, model, divergent=True, axes=None, day_labeler=DayLabeler(), time_labeler=TimeLabeler())
Plot the model predictions compared to the test data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X_to_predict
|
ndarray
|
Data for the model |
required |
X_holdout
|
ndarray
|
Holdout data for the model |
required |
model
|
LatentCalendar
|
LatentCalendar model instance |
required |
divergent
|
bool
|
Option to change the data displayed |
True
|
axes
|
Iterable[Axes]
|
list of 3 axes to plot this data |
None
|
Returns:
Type | Description |
---|---|
Iterable[Axes]
|
The axes used for plotting |
Source code in latent_calendar/plot/core/model.py
plot_profile(array, model, divergent=True, axes=None, include_components=True, day_labeler=DayLabeler(), time_labeler=TimeLabeler())
Create a profile plot with 3 different plots.
Displays the raw data, predicted probability distribution, and latent breakdown.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
long array (n_timeslots, ) |
required |
model
|
LatentCalendar
|
LatentCalendar model instance |
required |
divergent
|
bool
|
Option to change the data displayed |
True
|
axes
|
Iterable[Axes]
|
list of 3 axes to plot this data |
None
|
include_components
|
bool
|
If the last component plot should be included |
True
|
day_labeler
|
DayLabeler
|
DayLabeler instance |
DayLabeler()
|
time_labeler
|
TimeLabeler
|
TimeLabeler instance |
TimeLabeler()
|
Returns:
Type | Description |
---|---|
ndarray
|
None |
Source code in latent_calendar/plot/core/model.py
plot_raw_data(array, ax, display_y_axis=True, day_labeler=DayLabeler(), time_labeler=TimeLabeler())
First plot of raw data.