Plotting

Heatmap

graspy.plot.heatmap(X, transform=None, figsize=(10, 10), title=None, context='talk', font_scale=1, xticklabels=False, yticklabels=False, cmap='RdBu_r', vmin=None, vmax=None, center=0, cbar=True, inner_hier_labels=None, outer_hier_labels=None, hier_label_fontsize=30, ax=None, title_pad=None)[source]

Plots a graph as a heatmap.

Parameters:
X : nx.Graph or np.ndarray object

Graph or numpy matrix to plot

transform : None, or string {'log', 'zero-boost', 'simple-all', 'simple-nonzero'}
  • 'log' :
    Plots the log of all nonzero numbers
  • 'zero-boost' :s
    Pass to ranks method. preserves the edge weight for all 0s, but ranks the other edges as if the ranks of all 0 edges has been assigned.
  • 'simple-all':
    Pass to ranks method. Assigns ranks to all non-zero edges, settling ties using the average. Ranks are then scaled by \(\frac{rank(\text{non-zero edges})}{n^2 + 1}\) where n is the number of nodes
  • 'simple-nonzero':
    Pass to ranks method. Same as simple-all, but ranks are scaled by \(\frac{rank(\text{non-zero edges})}{\text{# non-zero edges} + 1}\)
figsize : tuple of integers, optional, default: (10, 10)

Width, height in inches.

title : str, optional, default: None

Title of plot.

context : None, or one of {paper, notebook, talk (default), poster}

The name of a preconfigured set.

font_scale : float, optional, default: 1

Separate scaling factor to independently scale the size of the font elements.

xticklabels, yticklabels : bool or list, optional

If list-like, plot these alternate labels as the ticklabels.

cmap : str, list of colors, or matplotlib.colors.Colormap, default: 'RdBu_r'

Valid matplotlib color map.

vmin, vmax : floats, optional (default=None)

Values to anchor the colormap, otherwise they are inferred from the data and other keyword arguments.

center : float, default: 0

The value at which to center the colormap

cbar : bool, default: True

Whether to draw a colorbar.

inner_hier_labels : array-like, length of X's first dimension, default: None

Categorical labeling of the nodes. If not None, will group the nodes according to these labels and plot the labels on the marginal

outer_hier_labels : array-like, length of X's first dimension, default: None

Categorical labeling of the nodes, ignored without inner_hier_labels If not None, will plot these labels as the second level of a hierarchy on the marginals

hier_label_fontsize : int

size (in points) of the text labels for the inner_hier_labels and outer_hier_labels.

ax : matplotlib Axes, optional

Axes in which to draw the plot, otherwise will generate its own axes

title_pad : int, float or None, optional (default=None)

Custom padding to use for the distance of the title from the heatmap. Autoscales if None

Gridplot

graspy.plot.gridplot(X, labels=None, transform=None, height=10, title=None, context='talk', font_scale=1, alpha=0.7, sizes=(10, 200), palette='Set1', legend_name='Type', inner_hier_labels=None, outer_hier_labels=None, hier_label_fontsize=30, title_pad=None)[source]

Plots multiple graphs as a grid, with intensity denoted by the size of dots on the grid.

Parameters:
X : list of nx.Graph or np.ndarray object

List of nx.Graph or numpy arrays to plot

labels : list of str

List of strings, which are labels for each element in X. len(X) == len(labels).

transform : None, or string {'log', 'zero-boost', 'simple-all', 'simple-nonzero'}
  • 'log' :
    Plots the log of all nonzero numbers
  • 'zero-boost' :
    Pass to ranks method. preserves the edge weight for all 0s, but ranks the other edges as if the ranks of all 0 edges has been assigned.
  • 'simple-all':
    Pass to ranks method. Assigns ranks to all non-zero edges, settling ties using the average. Ranks are then scaled by \(\frac{rank(\text{non-zero edges})}{n^2 + 1}\) where n is the number of nodes
  • 'simple-nonzero':
    Pass to ranks method. Same as simple-all, but ranks are scaled by \(\frac{rank(\text{non-zero edges})}{\text{# non-zero edges} + 1}\)
height : int, optional, default: 10

Height of figure in inches.

title : str, optional, default: None

Title of plot.

context : None, or one of {paper, notebook, talk (default), poster}

The name of a preconfigured set.

font_scale : float, optional, default: 1

Separate scaling factor to independently scale the size of the font elements.

palette : str, dict, optional, default: 'Set1'

Set of colors for mapping the hue variable. If a dict, keys should be values in the hue variable

alpha : float [0, 1], default

alpha value of plotted gridplot points

sizes : length 2 tuple, default: (10, 200)

min and max size to plot edge weights

legend_name : string, default: 'Type'

Name to plot above the legend

inner_hier_labels : array-like, length of X's first dimension, default: None

Categorical labeling of the nodes. If not None, will group the nodes according to these labels and plot the labels on the marginal

outer_hier_labels : array-like, length of X's first dimension, default: None

Categorical labeling of the nodes, ignored without inner_hier_labels If not None, will plot these labels as the second level of a hierarchy on the marginals

hier_label_fontsize : int

size (in points) of the text labels for the inner_hier_labels and outer_hier_labels.

title_pad : int, float or None, optional (default=None)

Custom padding to use for the distance of the title from the heatmap. Autoscales if None

Pairplot

graspy.plot.pairplot(X, labels=None, col_names=None, title=None, legend_name=None, variables=None, height=2.5, context='talk', font_scale=1, palette='Set1', alpha=0.7, size=50, marker='.', diag_kind='auto')[source]

Plot pairwise relationships in a dataset.

Parameters:
X : array-like, shape (n_samples, n_features)

Input data.

labels : array-like or list, shape (n_samples), optional

Labels that correspond to each sample in X.

col_names : array-like or list, shape (n_features), optional

Names or labels for each feature in X. If not provided, the default will be Dimension 1, Dimension 2, etc.

title : str, optional, default: None

Title of plot.

legend_name : str, optional, default: None

Title of the legend.

variables : list of variable names, optional

Variables to plot based on col_names, otherwise use every column with a numeric datatype.

height : int, optional, default: 10

Height of figure in inches.

context : None, or one of {paper, notebook, talk (default), poster}

The name of a preconfigured set.

font_scale : float, optional, default: 1

Separate scaling factor to independently scale the size of the font elements.

palette : str, dict, optional, default: 'Set1'

Set of colors for mapping the hue variable. If a dict, keys should be values in the hue variable.

alpha : float, optional, default: 0.7

opacity value of plotter markers between 0 and 1

size : float or int, optional, default: 50

size of plotted markers

marker : string, optional, default: '.'

matplotlib style marker specification https://matplotlib.org/api/markers_api.html