pyemma.plots.plot_markov_model

pyemma.plots.plot_markov_model(P, pos=None, state_sizes=None, state_scale=1.0, state_colors='#ff5500', minflux=1e-06, arrow_scale=1.0, arrow_curvature=1.0, arrow_labels='weights', arrow_label_format='%10.2f', max_width=12, max_height=12, figpadding=0.2)

Plots a network representation of a Markov model transition matrix

This visualization is not optimized for large matrices. It is meant to be used for the visualization of small models with up to 10-20 states, e.g. obtained by a HMM coarse-graining. If used with large network, the automatic node positioning will be very slow and may still look ugly.

Parameters:
  • P (ndarray(n,n) or MSM object with attribute 'transition matrix') – Transition matrix or MSM object
  • pos (ndarray(n,2), optional, default=None) – User-defined positions to draw the states on. If not given, will try to place them automatically.
  • state_sizes (ndarray(n), optional, default=None) – User-defined areas of the discs drawn for each state. If not given, the stationary probability of P will be used
  • state_colors (string or ndarray(n), optional, default='#ff5500' (orange)) – Either a string with a Hex code for a single color used for all states, or an array of values in [0,1] which will result in a grayscale plot
  • minflux (float, optional, default=1e-6) – The minimal flux (p_i * p_ij) for a transition to be drawn
  • arrow_scale (float, optional, default=1.0) – Relative arrow scale. Set to a value different from 1 to increase or decrease the arrow width.
  • arrow_curvature (float, optional, default=1.0) – Relative arrow curvature. Set to a value different from 1 to make arrows more or less curved.
  • arrow_labels ('weights', None or a ndarray(n,n) with label strings. Optional, default='weights') – Strings to be placed upon arrows. If None, no labels will be used. If ‘weights’, the elements of P will be used. If a matrix of strings is given by the user these will be used.
  • arrow_label_format (str, optional, default='%10.2f') – The numeric format to print the arrow labels
  • = 12 (max_height) – The maximum figure width
  • = 12 – The maximum figure height
  • = 0.2 (figpadding) – The relative figure size used for the padding
Returns:

Return type:

The positions of states. Can be used later to plot a different network representation (e.g. the flux)

Examples

>>> P = np.array([[0.8,  0.15, 0.05,  0.0,  0.0],
...              [0.1,  0.75, 0.05, 0.05, 0.05],
...              [0.05,  0.1,  0.8,  0.0,  0.05],
...              [0.0,  0.2, 0.0,  0.8,  0.0],
...              [0.0,  0.02, 0.02, 0.0,  0.96]])
>>> plot_markov_model(P) 
array...