plotter.drawables.raw_histograms¶
class RawHist(Drawable)¶
Class for creating a 1D histogram from raw sample data.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
NArray1D[Any] | The array containing the raw data to bin and plot. |
nbins |
int or NArray1D[Any] or "auto", optional | The number of bins of the histogram, or the array containing the edges of the bins (matplotlib's own convention for Axes.hist's bins argument). Defaults to "auto". |
density |
bool, optional | If True, the histogram is normalized such that the integral over the range is 1. Defaults to False. |
cumulative |
bool, optional | If True, the cumulative histogram is plotted. Defaults to False. |
bin_vals |
NArray1D[F64] or None | The array with the values corresponding to each bin. It has shape (N_bins,). |
bins |
NArray1D[F64] or None | The array with the edges of each bin (flattened). It has shape (N_bins+1,). |
Defined attributes:
label_name: ClassVar[str]draw_kwargs: ClassVar[frozenset[str]]data: NArray1D[Any]nbins: int | NArray1D[Any] | strdensity: boolcumulative: boolbin_vals: NArray1D[F64] | Nonebins: NArray1D[F64] | None
Methods¶
draw¶
Draws the histogram on the canvas.
Args:
| Name | Type | Description |
|---|---|---|
canvas |
Canvas | ZoomInset | The canvas (or zoom-inset panel) to draw the histogram on. |
plot_n |
int, optional | The index of the subplot to draw on. Defaults to 0. |
label |
str, optional | The label for the histogram in the legend. Defaults to None. |
Keyword Arguments:
| Name | Type | Description |
|---|---|---|
bin_ranges |
tuple[float,float] | The tuple with the left and right limits of the bins. Defaults to None, which means (data.min(), data.max()). |
color |
str | The Matplotlib color of the histogram. Defaults to "royalblue". |
alpha |
float | The transparency of the histogram. Defaults to 0.8. |
filled |
bool | If True, the histogram is filled. Defaults to True. |
edgecolor |
str | The color of the histogram edges. Defaults to "cornflowerblue". |
lw |
float | The width of the histogram edges. Defaults to 0 if filled is True, else to 1.5. |
Raises:
| Type | Description |
|---|---|
| ValueError | If plot_n is out of range for canvas. |
| TypeError | If a keyword argument not listed above is given. |
class RawHist2D(Drawable)¶
Class for creating a 2D histogram from raw sample data.
Attributes:
| Name | Type | Description |
|---|---|---|
x |
NArray1D[Any] | The array containing the x values to plot. |
y |
NArray1D[Any] | The array containing the y values to plot. |
nbins |
int | tuple | list | NArray2D | The number of bins for the histogram. It can be: - an int for the same number of bins for both axes.- a tuple or list of two ints for the number of bins for x and y respectively.- a 2D array for the edges of the bins. |
density |
bool, optional | If True, the histogram is normalized such that the integral over the range is 1. Defaults to False. |
bin_vals |
NArray2D[F64] or None | The array with the values corresponding to each bin. It has shape (N_bins_X, N_bins_Y). |
xbins |
NArray1D[F64] or None | The array with the edges of each x-bin (flattened). It has shape (N_bins_X+1,). |
ybins |
NArray1D[F64] or None | The array with the edges of each y-bin (flattened). It has shape (N_bins_Y+1,). |
mappable |
QuadMesh or None | The mesh artist returned by hist2d, populated after draw runs. Pass it (via this RawHist2D) as a Colorbar's source. |
Defined attributes:
draw_kwargs: ClassVar[frozenset[str]]x: NArray1D[Any]y: NArray1D[Any]nbins: int | tuple[int, int] | list[int] | NArray2D[Any]density: boolbin_vals: NArray2D[F64] | Nonexbins: NArray1D[F64] | Noneybins: NArray1D[F64] | Nonemappable: QuadMesh | None
Methods¶
draw¶
Draws the 2D histogram on the canvas.
Args:
| Name | Type | Description |
|---|---|---|
canvas |
Canvas | ZoomInset | The canvas (or zoom-inset panel) to draw the histogram on. |
plot_n |
int, optional | The index of the subplot to draw on. Defaults to 0. |
Keyword Arguments:
| Name | Type | Description |
|---|---|---|
bin_ranges |
tuple[tuple[float,float],tuple[float,float]] | The tuple with the left and right limits of the bins (in x and y). Defaults to None, which means ((x.min(),x.max()),(y.min(),y.max()). |
colormap |
str | The Matplotlib colormap to use for the histogram. Defaults to "plasma". |
alpha |
float | The transparency of the histogram. Defaults to 1. |
log |
bool or tuple[bool, float] | Controls the scale of the colormap. - bool: True for a logarithmic scale, False for a linear one.- tuple: (False, _) for a linear scale, (True, 0) for a logarithmic one, (True, t) for a 'symlog' scale that is linear within (-t, t). Defaults to False. |
Raises:
| Type | Description |
|---|---|
| ValueError | If plot_n is out of range for canvas. |
| TypeError | If a keyword argument not listed above is given. |