tomodrgn.analysis.plot_by_cluster#

plot_by_cluster(x: ndarray, y: ndarray, labels: ndarray, labels_sel: int | ndarray[int], centers_xy: ndarray | None = None, centers_ind: ndarray | None = None, annotate: bool = False, s: int = 2, alpha: float = 0.1, cmap=None, **kwargs) Tuple[Figure, Axes][source]#

Plot all points x,y with colors per class labels, with optional annotations for each cluster center and corresponding label.

Parameters:
  • x – array of x coordinates to plot, shape (nptcls)

  • y – array of y coordinates to plot, shape (nptcls)

  • labels – array of cluster labels for each particle, shape (nptcls)

  • labels_sel – selected cluster labels to plot. If int, plot all classes matching label in range(labels_sel). If array of int, plot all classes matching label in labels_sel.

  • centers_xy – optionally an array of x,y coordinates of cluster centers to superimpose, shape (n_labels_sel, 2). Mutually exclusive with specifying centers_ind.

  • centers_ind – optionally an array indices indexing x and y as the cluster centers to superimpose, shape (n_labels_sel). Mutually exclusive with specifying centers_xy.

  • annotate – whether to annotate the plot with text labels corresponding to each cluster center

  • s – size of scatter points, passed to matplotlib.pyplot.scatter

  • alpha – transparency of scatter points, passed to matplotlib.pyplot.scatter

  • cmap – the matplotlib colormap from which to sample colors. See: https://matplotlib.org/stable/users/explain/colors/colormaps.html#classes-of-colormaps

  • kwargs – additional keyword arguments passed to matplotlib.pyplot.scatter

Returns:

matplotlib figure and axis