Barhplot
See Baseplot for inherited modules.
Barhplot
Bases: Baseplot
Bar 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 |
BarDatafier
|
The datafier instance |
required |
palettes |
list[str]
|
List of color palettes to generate bar colors, by default ["viridis"] |
['viridis']
|
post_update |
Callable[[Barhplot, i], None]
|
callback function for additional customization, by default lambda self, i: None |
lambda self, i: None
|
annot_bars |
bool
|
Sets bar annotations, by default True |
True
|
fixed_xlim |
bool
|
If False xlim 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
|
rounded_edges |
bool
|
Sets rounded bar edges, by default False |
False
|
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, annot_bars=True, rounded_edges=False, fixed_xlim=True, xticks=True, yticks=True, grid=True)
classmethod
get_ith_bar_attrs(i)
Prepares ith top columns and their respective attributes such as position, length, colors. Not meant to be used outside animation update.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
i |
int
|
Animation frame index |
required |
Returns:
Type | Description |
---|---|
SimpleNamespace
|
bar_rank, bar_length, top_cols, column_colors |
set_xylim(xlim=[], ylim=[], xoffset=5, yoffset=0.6)
Sets xlim and ylim.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xlim |
list[float]
|
x axis limits in this format [min, max], by default [min, max + xoffset] |
[]
|
ylim |
list[float]
|
y axis limits in this format [min, max], by default [0.5, n_bars + yoffset] |
[]
|
xoffset |
float
|
additional offset value for x axis max, by default 5 |
5
|
yoffset |
float
|
additional offset value for y axis max, by default 0.6 |
0.6
|
set_barh(bar_height=0.86, **kwargs)
Sets barh properties, addition kwargs are passed to ax.barh(**kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bar_height |
float
|
Height of the bars (Note this is horizontal barplot), by default 0.86 |
0.86
|
set_bar_annots(text_callback=lambda val: np.round(val, 2), xoffset=0.1, yoffset=-0.1, ha='left', **kwargs)
Sets bar annotation properties, additional kwargs are passed to ax.text(**kwargs)
.
(Note these annotations are the texts near the bars)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text_callback |
Callable[[float], Union[str, float]]
|
Callback function for customizing the text, by default lambda val:np.round(val, 2) |
lambda val: np.round(val, 2)
|
xoffset |
float
|
X offset relative to bar length, by default 0.1 |
0.1
|
yoffset |
float
|
Y offset relative to bar height, by default -0.1 |
-0.1
|
ha |
str
|
Horizontal alignment, by default "left" |
'left'
|
set_bar_border_props(edge_color='k', radius=0.5, pad=-0.004, mutation_aspect=0.2, **kwargs)
Sets bar border properties. Additional kwargs are passed to FancyBboxPatch
.
See https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.patches.FancyBboxPatch.html
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge_color |
str
|
Bar edge color, by default "k" |
'k'
|
radius |
float
|
Bar border radius, by default 0.5 |
0.5
|
pad |
float
|
See above link, by default -0.0040 |
-0.004
|
mutation_aspect |
float
|
See above link, by default 0.2 |
0.2
|