persim.plot_diagrams

persim.plot_diagrams(diagrams, plot_only=None, title=None, xy_range=None, labels=None, colormap='default', size=20, ax_color=array([0., 0., 0.]), diagonal=True, lifetime=False, legend=True, show=False, ax=None)[source]

A helper function to plot persistence diagrams.

Parameters:
  • diagrams (ndarray (n_pairs, 2) or list of diagrams) – A diagram or list of diagrams. If diagram is a list of diagrams, then plot all on the same plot using different colors.

  • plot_only (list of numeric) – If specified, an array of only the diagrams that should be plotted.

  • title (string, default is None) – If title is defined, add it as title of the plot.

  • xy_range (list of numeric [xmin, xmax, ymin, ymax]) – User provided range of axes. This is useful for comparing multiple persistence diagrams.

  • labels (string or list of strings) – Legend labels for each diagram. If none are specified, we use H_0, H_1, H_2,… by default.

  • colormap (string, default is 'default') –

    Any of matplotlib color palettes. Some options are ‘default’, ‘seaborn’, ‘sequential’. See all available styles with

    import matplotlib as mpl
    print(mpl.styles.available)
    

  • size (numeric, default is 20) – Pixel size of each point plotted.

  • ax_color (any valid matplotlib color type.) – See [https://matplotlib.org/api/colors_api.html](https://matplotlib.org/api/colors_api.html) for complete API.

  • diagonal (bool, default is True) – Plot the diagonal x=y line.

  • lifetime (bool, default is False. If True, diagonal is turned to False.) – Plot life time of each point instead of birth and death. Essentially, visualize (x, y-x).

  • legend (bool, default is True) – If true, show the legend.

  • show (bool, default is False) – Call plt.show() after plotting. If you are using self.plot() as part of a subplot, set show=False and call plt.show() only once at the end.