Baseplot
Baseplot
General Chart animation module that requires a valid time index.The data should be in this format where time is set to index
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datafier |
BaseDatafier
|
The datafier instance |
required |
palettes |
list[str]
|
List of color palettes to generate bar colors, by default ["viridis"] |
['viridis']
|
post_update |
Callable[[Baseplot, i], None]
|
callback function for additional customization, by default lambda self, i: None |
lambda self, i: None
|
fixed_xlim |
bool
|
If False xlim will gradually change in every frame, by default True |
True
|
fixed_ylim |
bool
|
If False ylim will gradually change in every frame, by default True |
True
|
xticks |
bool
|
Sets xticks, by default True |
True
|
yticks |
bool
|
Sets yticks, by default True |
True
|
grid |
bool
|
Sets xgrid, by default True |
True
|
post_update args
self: Baseplot instance
i: Frame index
example:
>>> def post_update(self, i):
>>> # sets log scale for x-axis
>>> self.ax.set_xscale("log")
from_df(data, time_format, ip_freq, palettes=['viridis'], post_update=lambda self, i: None, fixed_xlim=True, fixed_ylim=True, xticks=True, yticks=True, grid=True)
classmethod
generate_column_colors()
Generates column colors based on the given color palettes.
Returns:
Type | Description |
---|---|
dict[str, str]
|
dict containing column to color mapping |
set_column_colors(colors)
Sets column colors. If colors is a list, length of colors should be equal
to len(column_colors)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
colors |
Union[str, list[str], dict[str, str]]
|
Single color str or list of colors or dict of column to color mapping |
required |
set_xylim(xlim=[], ylim=[])
Sets xlim and ylim
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xlim |
list[float]
|
x axis limits in this format [min, max], by default [min date, max date] |
[]
|
ylim |
list[float]
|
y axis limits in this format [min, max], by default [min y val, max y val] |
[]
|
set_title(title, x=0, y=1.01, size=13, color='#777777', **kwargs)
Sets the plot title and additional kwargs are passed to plt.text(**kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
Title text |
required |
x |
float
|
x coordinate of the text, by default 0 |
0
|
y |
float
|
y coordinate, by default 1.01 |
1.01
|
size |
float
|
text size, by default 13 |
13
|
color |
str
|
text color, by default "#777777" |
'#777777'
|
set_xlabel(text, x=0.43, y=-0.09, size=13, color='#777777', **kwargs)
Sets the plot xlabel and additional kwargs are passed to plt.text(**kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The xlabel text |
required |
x |
float
|
X coordinate of the text, by default 0.43 |
0.43
|
y |
float
|
Y coordinate, by default -0.09 |
-0.09
|
size |
float
|
Text size, by default 13 |
13
|
color |
str
|
Text color, by default "#777777" |
'#777777'
|
set_time(callback=lambda i, datafier: datafier.data.index[i], x=0.97, y=0.27, size=46, weight=800, ha='right', color='#777777', **kwargs)
Annotates the time in the plot and additional kwargs are passed to plt.text(**kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback |
Callable[[int, BaseDatafier], str]
|
Callback function to customize the time text, by default |
lambda i, datafier: datafier.data.index[i]
|
x |
float
|
x coordinate of the text, by default 0.97 |
0.97
|
y |
float
|
y coordinate of the text, by default 0.27 |
0.27
|
size |
float
|
text size, by default 46 |
46
|
weight |
float
|
text weight, by default 800 |
800
|
ha |
str
|
horizontal alignment, by default "right" |
'right'
|
color |
str
|
text color, by default "#777777" |
'#777777'
|
callback args:
set_text(key, text=None, callback=None, x=0, y=0, size=13, color='#777777', **kwargs)
General function to add custom texts in the plot. Either text or callback should be passd but not both.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
Unique identifier for each texts, note: These keys, title, xlabel, time, are reserved. overwrite them if you wish to use callbacks instead of texts in title or xlabel |
required |
text |
str
|
The text to be added in the plot, by default None |
None
|
callback |
Callable[[int, pd.DataFrame], str]
|
Callback function to customize the text, by default None |
None
|
x |
float
|
X coordinate of the text, by default 0 |
0
|
y |
str
|
Y coordinate of the text, by default 0 |
0
|
size |
float
|
Text size, by default 13 |
13
|
color |
str
|
Text color, by default "#777777" |
'#777777'
|
Callback args:
remove_text(keys)
Removes texts by key
Parameters:
Name | Type | Description | Default |
---|---|---|---|
keys |
list[str]
|
key or List of keys to be removed |
required |
set_xticks(axis='x', colors='#777777', labelsize=12, **kwargs)
Sets xtick properties, additional kwargs are passed to ax.tick_params(**kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis |
str
|
Defines tick axis, by default "x" |
'x'
|
colors |
str
|
Sets tick color, by default "#777777" |
'#777777'
|
labelsize |
float
|
Sets tick size, by default 12 |
12
|
set_yticks(axis='y', colors='#777777', labelsize=10, **kwargs)
Sets ytick properties, additional kwargs are passed to ax.tick_params(**kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis |
str
|
Defines tick axis, by default "y" |
'y'
|
colors |
str
|
Sets tick color, by default "#777777" |
'#777777'
|
labelsize |
float
|
Sets tick size, by default 10 |
10
|
set_grid(which='major', axis='x', linestyle='-', grid_behind=True, **kwargs)
Sets the plots grid, additional kwargs are passed to ax.grid(**kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
which |
str
|
The grid lines to apply the changes on, by default "major" |
'major'
|
axis |
str
|
Sets the axis of the grid, by default "x" |
'x'
|
linestyle |
str
|
Grids line style, by default "-" |
'-'
|
grid_behind |
bool
|
Sets the grid behind the plot, by default True |
True
|