Artists#
- class biaplotter.artists.Artist(ax: ~matplotlib.axes._axes.Axes | None = None, data: ~numpy.ndarray | None = None, categorical_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
categorical_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
Abstract property for the artist's data.
Abstract property for the artist's visibility.
Abstract property for the indices into the colormap.
Attributes Summary
Stores axes to plot on
Stores the colormap to use for the artist
Methods Summary
draw
()Abstract method to draw or redraw the artist.
Properties Documentation
- data#
Abstract property for the artist’s data.
- visible#
Abstract property for the artist’s visibility.
- color_indices#
Abstract property for the indices into the colormap.
Attributes Documentation
- ax: Axes#
Stores axes to plot on
- categorical_colormap: Colormap#
Stores the colormap to use for the artist
Methods Documentation
- abstract draw()#
Abstract method to draw or redraw the artist.
- class biaplotter.artists.Scatter(ax: ~matplotlib.axes._axes.Axes | None = None, data: ~numpy.ndarray | None = None, categorical_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
categorical_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 is 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 scatter plot.
Gets or sets the visibility of the scatter plot.
Gets or sets the current color indices used for the scatter plot.
Gets or sets the size of the points in the scatter plot.
Attributes Summary
Stores axes to plot on
Stores the colormap to use for the artist
Methods Summary
draw
()Draws or redraws the scatter plot.
Signals Summary
Signal emitted when the data is changed.
Signal emitted when the color_indices are changed.
Properties Documentation
- data#
Gets or sets the data associated with the scatter plot.
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 is changed.
- visible#
Gets or sets the visibility of the scatter plot.
Triggers a draw idle command.
- Returns:
visible – visibility of the scatter plot.
- Return type:
bool
- color_indices#
Gets or sets the current color indices used for the scatter plot.
Triggers a draw idle command.
- Returns:
color_indices – indices to map to the categorical_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]
Attributes Documentation
- ax: Axes#
Stores axes to plot on
- categorical_colormap: Colormap#
Stores the colormap to use for the artist
Methods Documentation
- draw()#
Draws or redraws the scatter plot.
Signals Documentation
- data_changed_signal: Signal#
Signal emitted when the data is 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, categorical_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
categorical_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 categorical_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
Notes
Signals:
data_changed_signal emitted when the data is changed.
color_indices_changed_signal emitted when the color indices are changed.
Properties Summary
Gets or sets the data associated with the 2D histogram.
Gets or sets the visibility of the 2D histogram.
Gets or sets the current color indices used for the 2D histogram underlying data.
Gets or sets the number of bins for the histogram.
Gets or sets the colormap for the histogram.
Returns the 2D histogram matplotlib object.
Attributes Summary
Stores axes to plot on
Stores the colormap to use for the artist
Methods Summary
indices_in_above_threshold_patches
(threshold)Returns the indices of the points in that fall into the bins of the 2D histogram exceeding a specified threshold.
draw
()Draws or redraws the 2D histogram.
Signals Summary
Signal emitted when the data is changed.
Signal emitted when the color_indices are changed.
Properties Documentation
- data#
Gets or sets the data associated with the 2D histogram.
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 is changed.
- visible#
Gets or sets the visibility of the 2D histogram.
Triggers a draw idle command.
- Returns:
visible – visibility of the 2D histogram.
- Return type:
bool
- color_indices#
Gets or sets the current color indices used for the 2D histogram underlying data.
Triggers a draw idle command.
- Returns:
color_indices – indices to map to the overlay colormap. Accepts a scalar or an array.
- 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
- histogram_colormap#
Gets or sets the colormap for the histogram.
- Returns:
histogram_colormap – colormap for the histogram.
- Return type:
Colormap
- histogram#
Returns the 2D histogram matplotlib object.
- Returns:
histogram – 2D histogram matplotlib object.
- Return type:
Tuple[np.ndarray, np.ndarray, np.ndarray, QuadMesh]
Attributes Documentation
- ax: Axes#
Stores axes to plot on
- categorical_colormap: Colormap#
Stores the colormap to use for the artist
Methods Documentation
- indices_in_above_threshold_patches(threshold: int) List[int] #
Returns the indices of the points in that fall into the bins of the 2D histogram exceeding a specified threshold.
- 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 2D histogram.
Signals Documentation
- data_changed_signal: Signal#
Signal emitted when the data is changed.
- color_indices_changed_signal: Signal#
Signal emitted when the color_indices are changed.