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 Example:
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']
|
post_update
|
Callable[[Barhplot, i], None]
|
callback function for additional customization, by default |
lambda self, i: None
|
annot_bars
|
bool
|
Sets bar annotations, by default |
True
|
rounded_edges
|
bool
|
Sets rounded bar edges, by default |
False
|
fixed_xlim
|
bool
|
If False xlim will gradually change in every frame, by default |
True
|
xticks
|
bool
|
Sets xticks, by default |
True
|
yticks
|
bool
|
Sets yticks, by default |
True
|
grid
|
bool
|
Sets xgrid, by default |
True
|
set_frame_on
|
bool
|
Set whether the Axes rectangle patch is drawn., by default |
True
|
post_update args
self: Barhplot instancei: Current frame index
example:
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, set_frame_on=True)
classmethod
get_ith_bar_attrs(i)
Prepares ith top columns and their respective attributes such as position, length, colors.
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=None, ylim=None, 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] |
None
|
ylim
|
list[float]
|
y axis limits in this format [min, max], by default [0.5, n_bars + yoffset] |
None
|
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: round(val, 2)
|
xoffset
|
float
|
X offset relative to bar length, by default |
0.1
|
yoffset
|
float
|
Y offset relative to bar height, by default |
-0.1
|
ha
|
str
|
Horizontal alignment, by default |
'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'
|
radius
|
float
|
Bar border radius, by default |
0.5
|
pad
|
float
|
See above link, by default |
-0.004
|
mutation_aspect
|
float
|
See above link, by default |
0.2
|