Artists#
- class biaplotter.artists.Artist(ax: ~matplotlib.axes._axes.Axes | None = None, data: ~numpy.ndarray | None = None, overlay_colormap: ~matplotlib.colors.Colormap = <matplotlib.colors.LinearSegmentedColormap object>, color_indices: ~numpy.ndarray | None = None)#
Bases:
ABC
Abstract base class for artists in the BiAPlotter.
- Parameters:
ax (plt.Axes, optional) – axes to plot on, by default None
data ((N, 2) np.ndarray) – data to be plotted
overlay_colormap (Colormap, optional) – a colormap to use for the artist, by default cat10_mod_cmap from nap-plot-tools
color_indices ((N,) np.ndarray, optional) – array of indices to map to the colormap, by default None
Properties Summary
Gets or sets the current color indices used for the artist.
Gets or sets the data associated with the artist.
Gets or sets the IDs associated with the data.
Gets or sets the overlay colormap for the artist.
Gets or sets the visibility of the artist.
Gets or sets the x-axis label.
Gets or sets the x-axis label color.
Gets or sets the y-axis label.
Gets or sets the y-axis label color.
Attributes Summary
Stores axes to plot on
Methods Summary
draw
()Draws or redraws the artist.
Properties Documentation
- color_indices#
Gets or sets the current color indices used for the artist.
Triggers a draw idle command.
- Returns:
color_indices – indices to map to the overlay_colormap. Accepts a scalar or an array of integers.
- Return type:
(N,) np.ndarray[int] or int
Notes
- color_indices_changed_signalSignal
Signal emitted when the color indices are changed.
- data#
Gets or sets the data associated with the artist.
Updates colors if color_indices are set. Triggers a draw idle command.
- Returns:
data – data for the artist. Does not respond if set to None or empty array.
- Return type:
(N, 2) np.ndarray
Notes
- data_changed_signalSignal
Signal emitted when the data are changed.
- ids#
Gets or sets the IDs associated with the data.
- Returns:
ids – Array of IDs corresponding to the data points.
- Return type:
(N,) np.ndarray[int]
- overlay_colormap#
Gets or sets the overlay colormap for the artist.
- Returns:
overlay_colormap – colormap for the artist with a categorical attribute.
- Return type:
BiaColormap
- visible#
Gets or sets the visibility of the artist.
Triggers a draw idle command.
- Returns:
visible – visibility of the artist.
- Return type:
bool
- x_label_text#
Gets or sets the x-axis label.
- x_label_color#
Gets or sets the x-axis label color.
- y_label_text#
Gets or sets the y-axis label.
- y_label_color#
Gets or sets the y-axis label color.
Attributes Documentation
- ax: Axes#
Stores axes to plot on
Methods Documentation
- draw()#
Draws or redraws the artist.
- class biaplotter.artists.Scatter(ax: ~matplotlib.axes._axes.Axes | None = None, data: ~numpy.ndarray | None = None, overlay_colormap: ~matplotlib.colors.Colormap = <matplotlib.colors.LinearSegmentedColormap object>, color_indices: ~numpy.ndarray | None = None)#
Bases:
Artist
Scatter plot artist for the BiAPlotter.
Inherits all parameters and attributes from abstract Artist. For parameter and attribute details, see the abstract Artist class documentation.
- Parameters:
ax (plt.Axes, optional) – axes to plot on, by default None
data ((N, 2) np.ndarray) – data to be plotted
overlay_colormap (Colormap, optional) – a colormap to use for the artist, by default cat10_mod_cmap from nap-plot-tools
color_indices ((N,) np.ndarray[int] or int, optional) – array of indices to map to the colormap, by default None
Notes
Signals:
data_changed_signal emitted when the data are changed.
color_indices_changed_signal emitted when the color indices are changed.
Examples
>>> import numpy as np >>> import matplotlib.pyplot as plt >>> from biaplotter.artists import Scatter >>> data = np.random.rand(100, 2) >>> fig, ax = plt.subplots() >>> scatter = Scatter(ax) >>> scatter.data = data >>> scatter.visible = True >>> scatter.color_indices = np.linspace(start=0, stop=5, num=100, endpoint=False, dtype=int) >>> plt.show()
Properties Summary
Gets or sets the data associated with the artist.
Gets or sets the visibility of the artist.
Gets or sets the current color indices used for the artist.
Gets or sets the alpha value of the scatter plot.
Gets or sets the size of the points in the scatter plot.
Gets or sets the overlay colormap for the artist.
Gets or sets the normalization method for the color indices.
Attributes Summary
Stores axes to plot on
Methods Summary
draw
()Draws or redraws the artist.
Signals Summary
Signal emitted when the data are changed.
Signal emitted when the color_indices are changed.
Properties Documentation
- data#
Gets or sets the data associated with the artist.
Updates colors if color_indices are set. Triggers a draw idle command.
- Returns:
data – data for the artist. Does not respond if set to None or empty array.
- Return type:
(N, 2) np.ndarray
Notes
- data_changed_signalSignal
Signal emitted when the data are changed.
- visible#
Gets or sets the visibility of the artist.
Triggers a draw idle command.
- Returns:
visible – visibility of the artist.
- Return type:
bool
- color_indices#
Gets or sets the current color indices used for the artist.
Triggers a draw idle command.
- Returns:
color_indices – indices to map to the overlay_colormap. Accepts a scalar or an array of integers.
- Return type:
(N,) np.ndarray[int] or int
Notes
- color_indices_changed_signalSignal
Signal emitted when the color indices are changed.
- size#
Gets or sets the size of the points in the scatter plot.
Triggers a draw idle command.
- Returns:
size – size of the points in the scatter plot. Accepts a scalar or an array of floats.
- Return type:
float or (N,) np.ndarray[float]
- alpha#
Gets or sets the alpha value of the scatter plot.
- Returns:
alpha – alpha value of the scatter plot.
- Return type:
float
- overlay_colormap#
Gets or sets the overlay colormap for the artist.
- Returns:
overlay_colormap – colormap for the artist with a categorical attribute.
- Return type:
BiaColormap
- overlay_visible#
- color_normalization_method#
Gets or sets the normalization method for the color indices.
- Returns:
color_normalization_method – the normalization method for the color indices.
- Return type:
str
Attributes Documentation
- ax: plt.Axes#
Stores axes to plot on
Methods Documentation
- draw()#
Draws or redraws the artist.
Signals Documentation
- data_changed_signal: Signal#
Signal emitted when the data are changed.
- color_indices_changed_signal: Signal#
Signal emitted when the color_indices are changed.
- class biaplotter.artists.Histogram2D(ax: ~matplotlib.axes._axes.Axes | None = None, data: ~numpy.ndarray | None = None, overlay_colormap: ~matplotlib.colors.Colormap = <matplotlib.colors.LinearSegmentedColormap object>, color_indices: ~numpy.ndarray | None = None, bins=20, histogram_colormap: ~matplotlib.colors.Colormap = <matplotlib.colors.ListedColormap object>, cmin=0)#
Bases:
Artist
2D histogram artist for the BiAPlotter.
Inherits all parameters and attributes from abstract Artist. For parameter and attribute details, see the abstract Artist class documentation.
- Parameters:
ax (plt.Axes, optional) – axes to plot on, by default None
data ((N, 2) np.ndarray) – data to be plotted
overlay_colormap (Colormap, optional) – a colormap to use for the artist overlay, by default cat10_mod_cmap_first_transparent from nap-plot-tools (first color is transparent)
color_indices ((N,) np.ndarray[int] or int, optional) – array of indices to map to the overlay_colormap, by default None
bins (int, optional) – number of bins for the histogram, by default 20
histogram_colormap (Colormap, optional) – colormap for the histogram, by default plt.cm.magma
cmin (int, optional) – minimum count for the histogram, by default 0 Values below cmin are set to NaN (to be transparent).
Notes
Signals:
data_changed_signal emitted when the data are changed.
color_indices_changed_signal emitted when the color indices are changed.
Properties Summary
Gets or sets the data associated with the artist.
Gets or sets the visibility of the artist.
Gets or sets the current color indices used for the artist.
Gets or sets the number of bins for the histogram.
Gets or sets the minimum count for the histogram.
Returns the 2D histogram array and edges.
Gets or sets the colormap for the histogram.
Gets or sets the interpolation method for the histogram.
Gets or sets the normalization method for the histogram.
Gets or sets the overlay colormap for the artist.
Gets or sets the interpolation method for the overlay histogram.
Gets or sets the normalization method for the overlay histogram.
Gets or sets the opacity of the overlay histogram.
Gets or sets the visibility of the overlay histogram.
Attributes Summary
Stores axes to plot on
Methods Summary
indices_in_patches_above_threshold
(threshold)Returns the indices of the points that fall into the bins of the 2D histogram exceeding a specified threshold counts value.
draw
()Draws or redraws the artist.
Signals Summary
Signal emitted when the data are changed.
Signal emitted when the color_indices are changed.
Properties Documentation
- data#
Gets or sets the data associated with the artist.
Updates colors if color_indices are set. Triggers a draw idle command.
- Returns:
data – data for the artist. Does not respond if set to None or empty array.
- Return type:
(N, 2) np.ndarray
Notes
- data_changed_signalSignal
Signal emitted when the data are changed.
- visible#
Gets or sets the visibility of the artist.
Triggers a draw idle command.
- Returns:
visible – visibility of the artist.
- Return type:
bool
- color_indices#
Gets or sets the current color indices used for the artist.
Triggers a draw idle command.
- Returns:
color_indices – indices to map to the overlay_colormap. Accepts a scalar or an array of integers.
- Return type:
(N,) np.ndarray[int] or int
Notes
- color_indices_changed_signalSignal
Signal emitted when the color indices are changed.
- bins#
Gets or sets the number of bins for the histogram.
- Returns:
bins – number of bins for the histogram.
- Return type:
int
- cmin#
Gets or sets the minimum count for the histogram.
Values below cmin are set to NaN (to be transparent).
- Returns:
cmin – minimum count for the histogram.
- Return type:
int
- histogram#
Returns the 2D histogram array and edges.
- Returns:
histogram – 2D histogram, x edges, and y edges.
- Return type:
Tuple[np.ndarray, np.ndarray, np.ndarray]
- histogram_colormap#
Gets or sets the colormap for the histogram.
- Returns:
histogram_colormap – colormap for the histogram.
- Return type:
Colormap
- histogram_interpolation#
Gets or sets the interpolation method for the histogram.
- Returns:
histogram_interpolation – interpolation method for the histogram.
- Return type:
str
- histogram_color_normalization_method#
Gets or sets the normalization method for the histogram.
- Returns:
color_normalization_method – the normalization method for the histogram.
- Return type:
str
- overlay_colormap#
Gets or sets the overlay colormap for the artist.
- Returns:
overlay_colormap – colormap for the artist with a categorical attribute.
- Return type:
BiaColormap
- overlay_interpolation#
Gets or sets the interpolation method for the overlay histogram.
- Returns:
overlay_interpolation – interpolation method for the overlay histogram.
- Return type:
str
- overlay_color_normalization_method#
Gets or sets the normalization method for the overlay histogram.
- Returns:
overlay_color_normalization_method – the normalization method for the overlay color indices.
- Return type:
str
- overlay_opacity#
Gets or sets the opacity of the overlay histogram.
Triggers a draw idle command.
- Returns:
overlay_opacity – opacity of the overlay histogram.
- Return type:
float
- overlay_visible#
Gets or sets the visibility of the overlay histogram.
Triggers a draw idle command.
- Returns:
overlay_visible – visibility of the overlay histogram.
- Return type:
bool
Attributes Documentation
- ax: plt.Axes#
Stores axes to plot on
Methods Documentation
- indices_in_patches_above_threshold(threshold: int) List[int] #
Returns the indices of the points that fall into the bins of the 2D histogram exceeding a specified threshold counts value.
- Parameters:
threshold (int) – The count threshold to exceed.
- Returns:
indices – list of indices of points falling into the exceeding bins.
- Return type:
List[int]
- draw()#
Draws or redraws the artist.
Signals Documentation
- data_changed_signal: Signal#
Signal emitted when the data are changed.
- color_indices_changed_signal: Signal#
Signal emitted when the color_indices are changed.