Plotting Functions
- pydtmc.plot_comparison(models, underlying_matrices='transition', names=None, dpi=100)[source]
The function plots the underlying matrices of the given models in the form of a heatmap.
Notes:If Matplotlib is in interactive mode, the plot is immediately displayed and the function does not return the plot handles.
- Parameters:
models (
List
[Union
[HiddenMarkovModel
,MarkovChain
]]) – the models.underlying_matrices (
str
)emission for comparing the emission matrices;
transition for comparing the transition matrices.
names (
Optional
[List
[str
]]) – the name of each model subplot (if omitted, a standard name is given to each subplot).dpi (
int
) – the resolution of the plot expressed in dots per inch.
- Raises:
ValidationError
– if any input argument is not compliant.- Return Type:
- pydtmc.plot_eigenvalues(model, dpi=100)[source]
The function plots the eigenvalues of the transition matrix of the given model on the complex plane.
Notes:If Matplotlib is in interactive mode, the plot is immediately displayed and the function does not return the plot handles.
- Parameters:
model (
Union
[HiddenMarkovModel
,MarkovChain
]) – the model.dpi (
int
) – the resolution of the plot expressed in dots per inch.
- Raises:
ValidationError
– if any input argument is not compliant.- Return Type:
- pydtmc.plot_flow(model, steps, interval, initial_status=None, palette='viridis', dpi=100)[source]
The function produces an alluvial diagram of the given model.
Notes:If Matplotlib is in interactive mode, the plot is immediately displayed and the function does not return the plot handles.
- Parameters:
model (
Union
[HiddenMarkovModel
,MarkovChain
]) – the model.steps (
int
) – the number of steps.interval (
int
) – the interval between each step.initial_status (
Optional
[Union
[int
,str
,ndarray
,spmatrix
]]) – the initial state or the initial distribution of the states (if omitted, the states are assumed to be uniformly distributed).palette (
str
) – the palette of the plot.dpi (
int
) – the resolution of the plot expressed in dots per inch.
- Raises:
ValidationError
– if any input argument is not compliant.- Return Type:
- pydtmc.plot_graph(model, nodes_color=True, nodes_shape=True, edges_label=True, force_standard=False, dpi=100)[source]
The function plots the directed graph of the given model.
Notes:If Matplotlib is in interactive mode, the plot is immediately displayed and the function does not return the plot handles.
Graphviz and pydot are not required, but they provide access to extended mode with improved rendering and additional features.
The rendering, especially in standard mode or for big graphs, is not granted to be high-quality.
For Markov chains, the color of nodes is based on communicating classes; for hidden Markov models, every state node has a different color and symbol nodes are gray.
For Markov chains, recurrent nodes have an elliptical shape and transient nodes have a rectangular shape; for hidden Markov models, state nodes have an elliptical shape and symbol nodes have a hexagonal shape.
- Parameters:
model (
Union
[HiddenMarkovModel
,MarkovChain
]) – the model.nodes_color (
bool
) – a boolean indicating whether to use a different color for every type of node.nodes_shape (
bool
) – a boolean indicating whether to use a different shape for every type of node.edges_label (
bool
) – a boolean indicating whether to display the probability of every edge as text.force_standard (
bool
) – a boolean indicating whether to use standard mode even if extended mode is available.dpi (
int
) – the resolution of the plot expressed in dots per inch.
- Raises:
ValidationError
– if any input argument is not compliant.- Return Type:
- pydtmc.plot_redistributions(model, redistributions, initial_status=None, plot_type='projection', dpi=100)[source]
The function plots a redistribution of states on the given model.
Notes:If Matplotlib is in interactive mode, the plot is immediately displayed and the function does not return the plot handles.
- Parameters:
model (
Union
[HiddenMarkovModel
,MarkovChain
]) – the model to be converted into a graph.redistributions (
int
) – the number of redistributions to perform.initial_status (
Optional
[Union
[int
,str
,ndarray
,spmatrix
]]) – the initial state or the initial distribution of the states (if omitted, the states are assumed to be uniformly distributed).plot_type (
str
)heatmap for displaying a heatmap plot;
projection for displaying a projection plot.
dpi (
int
) – the resolution of the plot expressed in dots per inch.
- Raises:
ValidationError
– if any input argument is not compliant.ValueError
– if the “distributions” parameter represents a sequence of redistributions and the “initial_status” parameter does not match its first element.
- Return Type:
- pydtmc.plot_sequence(model, steps, initial_state=None, plot_type='histogram', seed=None, dpi=100)[source]
The function plots a random walk on the given model.
Notes:If Matplotlib is in interactive mode, the plot is immediately displayed and the function does not return the plot handles.
- Parameters:
model (
Union
[HiddenMarkovModel
,MarkovChain
]) – the model.steps (
int
) – the number of steps.initial_state (
Optional
[Union
[int
,str
]]) – the initial state of the random walk (if omitted, it is chosen uniformly at random).plot_type (
str
)heatmap for displaying heatmap-like plots;
histogram for displaying a histogram plots;
matrix for displaying matrix plots.
seed (
Optional
[int
]) – a seed to be used as RNG initializer for reproducibility purposes.dpi (
int
) – the resolution of the plot expressed in dots per inch.
- Raises:
ValidationError
– if any input argument is not compliant.- Return Type: