anyplotlib.PlotBar#
- class anyplotlib.PlotBar(x, height=None, width=0.8, bottom=0.0, *, align='center', color='#4fc3f7', colors=None, orient='v', log_scale=False, group_labels=None, group_colors=None, show_values=False, units='', y_units='', x_labels=None, x_centers=None, bar_width=None, baseline=None, values=None)[source]#
Bases:
_BasePlot,_PanelMixinBar-chart plot panel.
Not an anywidget. Holds state in
_statedict; every mutation calls_push()which writes to the parent Figure’s panel trait.Supports grouped bars (pass a 2-D height array with shape
(N, G)), log-scale value axis, draggable overlay widgets, and hover/click callbacks.Created by
Axes.bar().- Parameters:
- set_data(height, x=None, x_labels=None, *, x_centers=None)[source]#
Replace bar heights; recalculates the value-axis range automatically.
- Parameters:
height (array-like, shape
(N,)or(N, G)) – New bar heights. For grouped charts the group count G must match the original.x (array-like of numeric, optional) – New bar positions (replaces the stored
x_centers). Also accepts the legacy keyword aliasx_centers.
- Return type:
None
- set_color(color)[source]#
Set a single colour for all bars.
- Parameters:
color (str)
- Return type:
None
- set_colors(colors)[source]#
Set per-bar colours (list of CSS colour strings, length N).
- Return type:
None
- set_show_values(show)[source]#
Show or hide in-bar value annotations.
- Parameters:
show (bool)
- Return type:
None
- set_log_scale(log_scale)[source]#
Enable or disable a logarithmic value axis.
When log_scale is
Trueany non-positive values are clamped to1e-10for display; the data-range bounds are recalculated in log-space automatically.- Parameters:
log_scale (bool)
- Return type:
None
- set_xlabel(label, fontsize=None)[source]#
Set the x-axis label (mini-TeX allowed; default size 10 px).
- set_ylabel(label, fontsize=None)[source]#
Set the y-axis / value-axis label (mini-TeX allowed; default size 10 px).
- set_align(align)[source]#
Set bar alignment:
'center'or'edge'.- Parameters:
align (str)
- Return type:
None
- set_orient(orient)[source]#
Set bar orientation:
'v'(vertical) or'h'(horizontal).- Parameters:
orient (str)
- Return type:
None
- set_group_labels(labels)[source]#
Replace the category labels on the category axis.
- Return type:
None
- add_vline_widget(x, color='#00e5ff')[source]#
Add a draggable vertical line at data position x.
- Parameters:
- Return type:
- add_hline_widget(y, color='#00e5ff')[source]#
Add a draggable horizontal line at value-axis position y.
- Parameters:
- Return type:
- add_range_widget(x0, x1, color='#00e5ff', style='band', y=0.0, _push=True)[source]#
Add a draggable range overlay. See
Plot1D.add_range_widget()for full docs.