neuralib.plot.tools.AxesExtendHelper
- class neuralib.plot.tools.AxesExtendHelper[source]
Bases:
objectAdd 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', x_position='top', y_position='right', x_gap=0.05, y_gap=0.05, x_size=0.25, y_size=0.25)[source]
- Parameters:
ax (Axes) –
matplotlib.axes.Axesmode (Literal['both', 'x', 'y']) – extended axis {‘both’, ‘x’, ‘y’}. default is to add both
x_position (Literal['top', 'bottom']) – position of x-axis marginal plot {‘top’, ‘bottom’}. default is ‘top’
y_position (Literal['right', 'left']) – position of y-axis marginal plot {‘right’, ‘left’}. default is ‘right’
x_gap (float) – gap between main axis and x marginal plot (default 0.05)
y_gap (float) – gap between main axis and y marginal plot (default 0.05)
x_size (float) – height of x marginal plot (default 0.25)
y_size (float) – width of y marginal plot (default 0.25)
Methods
__init__(ax[, mode, x_position, y_position, ...])xbar(x, height[, width])x axis bar
xhist(values, bins, **kwargs)x axis histogram
ybar(y, width[, height])y axis bar
yhist(values, bins, **kwargs)y axis histogram
Attributes
- __init__(ax, mode='both', x_position='top', y_position='right', x_gap=0.05, y_gap=0.05, x_size=0.25, y_size=0.25)[source]
- Parameters:
ax (Axes) –
matplotlib.axes.Axesmode (Literal['both', 'x', 'y']) – extended axis {‘both’, ‘x’, ‘y’}. default is to add both
x_position (Literal['top', 'bottom']) – position of x-axis marginal plot {‘top’, ‘bottom’}. default is ‘top’
y_position (Literal['right', 'left']) – position of y-axis marginal plot {‘right’, ‘left’}. default is ‘right’
x_gap (float) – gap between main axis and x marginal plot (default 0.05)
y_gap (float) – gap between main axis and y marginal plot (default 0.05)
x_size (float) – height of x marginal plot (default 0.25)
y_size (float) – width of y marginal plot (default 0.25)
- ax_x: Axes | None
- ax_y: Axes | None
- xhist(values, bins, **kwargs)[source]
x axis histogram
- Parameters:
values (ndarray[tuple[Any, ...], dtype[Any]] | Sequence[Any] | pd.Series | pl.Series) – 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 (ndarray[tuple[Any, ...], dtype[Any]] | Sequence[Any] | pd.Series | pl.Series) – histogram x axis
bins (int | Sequence[float] | str | None) – number of bins
kwargs – additional arguments passed to
Axes.hist()