neuralib.plot.plot
- neuralib.plot.plot.dotplot(xlabel, ylabel, values, *, scale='area', max_marker_size=None, size_title=None, size_legend_num=None, size_legend_as_int=True, with_color=False, cmap='Reds', colorbar_title=None, norm=None, cbar_vmin=None, cbar_vmax=None, figure_title=None, figure_output=None, ax=None, **kwargs)[source]
Plot values as dots, with the option also in colormap
Dimension parameters:
X = number of x label
Y = number of y label
- Parameters:
xlabel (ArrayLikeStr) – String arraylike. ArrayLike[str, X]
ylabel (ArrayLikeStr) – String arraylike. ArrayLike[str, X]
values (np.ndarray) – 2D value array. ArrayLike[str, [X, Y]]
scale (Literal['area', 'radius']) – Dot size representation. {‘area’, ‘radius’}
max_marker_size (float | None) – Marker size for the max value
size_title (str | None) – Size_title in the size legend
size_legend_num (int | None) – Number of legend to be shown
size_legend_as_int (bool) – Size legend show only Int
with_color (bool) – If dot with colormap
cmap (mcolors.Colormap) –
Colormapcolorbar_title (str | None) – Title of the colorbar
norm (mcolors.Normalize | None) – Colorbar Normalize
cbar_vmin (float | None) – Value min for the colorbar
cbar_vmax (float | None) – Value nax for the colorbar
figure_title (str | None) – Figure title
figure_output (PathLike | None) – Figure save output path
ax (Axes | None) – If existing axes
Axeskwargs – additional arguments to
ax.scatter()
- neuralib.plot.plot.scatter_histogram(x, y, bins=15, *, linear_reg=True, output=None, **kwargs)[source]
plot the linear correlation scatter and histogram between two variables
Dimension parameters:
N = number of sample points
- Parameters:
x (np.ndarray) – numerical array x. Array[float, N]
y (np.ndarray) – numerical array y. Array[float, N]
bins (int | Sequence[float] | str) – passed to
numpy.histogram()linear_reg (bool) – If show correlation coefficient
output (Path | None) – Figure save output
kwargs – additional args pass through
ax.set()
- Returns:
- neuralib.plot.plot.scatter_binx_plot(ax, x, y, bins=10, *, order=1, linear_reg=True, bin_func='median', **kwargs)[source]
Regression to see the relationship between x and y
Dimension parameters:
N = number of sample points
- Parameters:
ax (Axes) –
Axesx (np.ndarray) – Numerical array. Array[float, N]
y (np.ndarray) – Numerical array. Array[float, N]
bins (int | Sequence[float] | str) – passed to
numpy.histogram()order (int) – If order is greater than 1, use numpy.polyfit to estimate a polynomial regression
linear_reg (bool) – Show linear correlation coefficient
bin_func (Literal['median', 'mean']) – Literal[‘median’, ‘mean’]. default is median
kwargs – additional args passed to
ax.set
- Returns:
- neuralib.plot.plot.hist_cutoff(ax, values, cutoff, bins=30, *, mask=None, **kwargs)[source]
Plot the histogram with a cutoff value
- Parameters:
ax (Axes) –
Axesvalues (np.ndarray) – 1d array. Array[float, N]
cutoff (float) – cutoff (threshold) value for the certain value, >= represents pass
bins (int) – passed to
numpy.histogram()mask (np.ndarray | None) – mask for value. i.e., cell selection. Array[bool, N]
kwargs – passed to
ax.set
- Return type:
None
- neuralib.plot.plot.violin_boxplot(ax, data, x=None, y=None, hue=None, scatter_alpha=0.7, scatter_size=3, output=None, **kwargs)[source]
Plot the data with half violin together with boxes and scatters
- Parameters:
ax (Axes) –
Axesdata (DataFrame | dict | list[np.ndarray]) – Dataset for plotting
x (str | None) – Names of variables in data or vector data:
xy (str | None) – Names of variables in data or vector data:
yhue (str | None) – Names of variables in data or vector data:
huescatter_alpha (float) – Scatter alpha for the
sns.stripplot()scatter_size (float) – Scatter size for the
sns.stripplot()output (PathLike | None) – Fig save output path
kwargs – Common args pass through
sns.violinplot(),sns.boxplot()andsns.stripplot()
- Returns:
- Return type:
None
- neuralib.plot.plot.grid_subplots(data, images_per_row, plot_func, *, dtype, hide_axis=True, sharex=False, sharey=False, title=None, figsize=None, output=None, **kwargs)[source]
Plots a sequence of subplots in a grid format
Example for plot xy grid:
>>> data = np.random.sample((30, 10, 2)) >>> grid_subplots(data, 5, 'plot', dtype='xy')
Example for plot img array grid
>>> data = np.random.sample((30, 10, 10)) >>> grid_subplots(data, 5, 'imshow', dtype='img', cmap='gray')
- Parameters:
data (np.ndarray | list[np.ndarray]) – 3D Array containing the data to be plotted. For ‘xy’ dtype, the shape must be (N, (*, 2)). For ‘img’ dtype, the shape must be (N, (*img)). Accepted also list of 2D array different size
images_per_row (int) – Number of images per row in the subplot grid
plot_func (Callable | str) – Function or method name to be used for plotting. If a string is provided, it should be a valid method name of a matplotlib Axes object
dtype (Literal['xy', 'img']) – {‘xy’, ‘img’}. Type of data. ‘xy’ for (x, y) coordinate data, ‘img’ for image data
hide_axis (bool) – If True, hides the axes of the subplots
sharex (bool) – sharex acrross grid plots
sharey (bool) – sharey acrross grid plots
title (list[str] | None) – List of title foreach show in the subplot
figsize (tuple[int, int] | None) – Figure_size pass to
plt.subplots()output (PathLike | None) – Path to save the plot image. If None, displays the plot.
kwargs – Additional keyword arguments passed to the plotting function
plot_func
- Returns:
- Return type:
None