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, _PanelMixin

Bar-chart plot panel.

Not an anywidget. Holds state in _state dict; 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:
to_state_dict()[source]#
Return type:

dict

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 alias x_centers.

  • x_labels (list of str, optional) – New category labels.

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 True any non-positive values are clamped to 1e-10 for 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).

Parameters:
Return type:

None

set_ylabel(label, fontsize=None)[source]#

Set the y-axis / value-axis label (mini-TeX allowed; default size 10 px).

Parameters:
Return type:

None

set_bar_width(width)[source]#

Set the bar width.

Parameters:

width (float)

Return type:

None

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

set_xlim(xmin, xmax)[source]#

Pan/zoom the x-axis to [xmin, xmax] in data coordinates.

Parameters:
Return type:

None

set_ylim(y_min, y_max)[source]#

Fix the value-axis range to [y_min, y_max].

Parameters:
Return type:

None

get_ylim()[source]#

Return the current value-axis range as (y_min, y_max).

Return type:

tuple

get_xlim()[source]#

Return the current x-axis view range in data coordinates.

Return type:

tuple

reset_view()[source]#

Reset pan/zoom to show all bars.

Return type:

None

add_vline_widget(x, color='#00e5ff')[source]#

Add a draggable vertical line at data position x.

Parameters:
Return type:

VLineWidget

add_hline_widget(y, color='#00e5ff')[source]#

Add a draggable horizontal line at value-axis position y.

Parameters:
Return type:

HLineWidget

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.

Parameters:
Return type:

RangeWidget

add_point_widget(x, y, color='#00e5ff', show_crosshair=True, _push=True)[source]#

Add a freely-draggable control point to this panel.

Parameters:
Return type:

PointWidget