plotter.drawables.bars¶
class BarChart(Drawable)¶
Class for creating a bar chart.
Attributes:
| Name | Type | Description |
|---|---|---|
x |
NArray1D[Any] | The array containing the x positions of the bars. |
heights |
NArray1D[Any] | The array containing the heights of the bars. |
yerr |
NArray1D[Any] | float | None, optional | The uncertainty on the bar heights. If a float is passed, all the errors are assumed identical. |
Raises:
| Type | Description |
|---|---|
| ValueError | If x and heights do not have the same dimensions. |
| ValueError | If yerr as an array does not have the same dimensions as heights. |
Defined attributes:
label_name: ClassVar[str]x: NArray1D[Any]heights: NArray1D[Any]yerr: NArray1D[Any] | float | None
Methods¶
draw¶
draw(self, canvas: Canvas | ZoomInset, plot_n: int=0, label: str | None=None, bar_labels: bool | dict[str, Any]=False, **kwargs) -> None
Draws the bar chart on the canvas.
Args:
| Name | Type | Description |
|---|---|---|
canvas |
Canvas | ZoomInset | The canvas (or zoom-inset panel) to draw the bar chart on. |
plot_n |
int, optional | The index of the subplot to draw on. Defaults to 0. |
label |
str, optional | The label for the bar chart in the legend. Defaults to None. |
bar_labels |
bool | dict[str, Any], optional | If truthy, writes a text label above each bar via Axes.bar_label. Pass True for the default behavior (each bar's height, formatted with matplotlib's "%g" format), or a dict of keyword arguments forwarded straight through to Axes.bar_label -- e.g. {"labels": \[...\]} for custom per-bar text, or "fmt"/"label_type"/"padding"/any Text styling kwarg. Defaults to False. |
Keyword Arguments:
| Name | Type | Description |
|---|---|---|
bottom |
float | NArray1D[Any] | The y-coordinate(s) of each bar's base. Pass the previous series' (cumulative) heights to stack bar charts on top of each other -- see plotter.helpers.useful_functions.stack_bottoms for computing this across more than two series. Defaults to 0. |
width |
float | The width of the bars. Defaults to 0.8. |
color |
str | The Matplotlib color of the bars. Defaults to "steelblue". |
alpha |
float | The transparency of the bars. Defaults to 0.9. |
err_color |
str | The color of the error bars. Defaults to "black". |
err_width |
float | The width of the error bars. Defaults to 1.5. |
err_capsize |
float | The size of the error bar ticks. Defaults to 3. |
lw |
float | The width of the bar edges. Defaults to 0. |
edgecolor |
str | The color of the bar edges. Defaults to "midnightblue". |