neuralib.plot.tools
- class neuralib.plot.tools.AnchoredScaleBar[source]
- __init__(transform, sizex=0, sizey=0, labelx=None, labely=None, loc=4, pad=0.1, borderpad=0.1, sep=2, color='black', lw=1.5, color_txt='black', prop=None, **kwargs)[source]
Set of scale bars that match the size of the ticks of the plot.
Draws a horizontal and/or vertical bar with the size in data coordinates of the give axes. A label will be drawn underneath (center-aligned).
- Parameters:
transform (Transform) – Matplotlib Transform The coordinate frame (typically axes.transData)
sizex (float) – Width of x bar, in data units. 0 to omit.
sizey (float) – Width of y bar, in data units. 0 to omit.
labelx (str | None) – Labels for x bars; None to omit
labely (str | None) – Labels for y bars; None to omit
loc (int | str) – Position in containing axes.
pad (float) – Padding, in fraction of the legend font size (or prop).
borderpad
sep (int) – Separation between labels and bars in points.
color (str) – Bars color
lw (float) – Bars width
color_txt (str) – color
prop – Font property.
kwargs – additional arguments passed to base class constructor
- set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, bbox_to_anchor=<UNSET>, child=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, gid=<UNSET>, height=<UNSET>, in_layout=<UNSET>, label=<UNSET>, mouseover=<UNSET>, offset=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, width=<UNSET>, zorder=<UNSET>)
Set multiple properties at once.
Supported properties are
- Properties:
agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: scalar or None animated: bool bbox_to_anchor: unknown child: unknown clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None figure: ~matplotlib.figure.Figure gid: str height: float in_layout: bool label: object mouseover: bool offset: (float, float) or callable path_effects: list of .AbstractPathEffect picker: None or bool or float or callable rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None transform: ~matplotlib.transforms.Transform url: str visible: bool width: float zorder: float
- class neuralib.plot.tools.AxesExtendHelper[source]
Add a child inset Axes to this existing Axes
Example of add hist:
>>> from neuralib.plot import plot_figure >>> x = np.random.sample(10) >>> y = np.random.sample(10) >>> with plot_figure(None) as ax: ... ax.plot(x, y, 'k.') ... helper = AxesExtendHelper(ax) ... helper.xhist(x, bins=10) ... helper.yhist(y, bins=10)
Example of add bar:
>>> from neuralib.plot import plot_figure >>> img = np.random.sample((10, 10)) >>> with plot_figure(None) as ax: ... ax.imshow(img) ... helper = AxesExtendHelper(ax) ... x = y = np.arange(10) ... helper.xbar(x, np.mean(img, axis=0), align='center') ... helper.ybar(y, np.mean(img, axis=1), align='center')
- __init__(ax, mode='both')[source]
- Parameters:
ax (Axes) –
matplotlib.axes.Axesmode (Literal['both', 'x', 'y']) – extended axis {‘both’, ‘x’, ‘y’}. default is to add both
- ax_x: Axes | None
- ax_y: Axes | None
- xhist(values, bins, **kwargs)[source]
x axis histogram
- Parameters:
values (ArrayLike) – histogram x axis
bins (int | Sequence[float] | str | None) – number of bins
kwargs – additional arguments passed to
Axes.hist()
- yhist(values, bins, **kwargs)[source]
y axis histogram
- Parameters:
values (ArrayLike) – histogram x axis
bins (int | Sequence[float] | str | None) – number of bins
kwargs – additional arguments passed to
Axes.hist()