plot_static_mapper_graph¶
-
gtda.mapper.visualization.
plot_static_mapper_graph
(pipeline, data, layout='kamada_kawai', layout_dim=2, color_variable=None, node_color_statistic=None, color_by_columns_dropdown=False, plotly_kwargs=None, clone_pipeline=True)[source]¶ Plotting function for static Mapper graphs.
Nodes are colored according to
color_variable
. By default, the hovertext displays a globally unique ID and the number of elements associated with a given node.- Parameters
pipeline (
MapperPipeline
object) – Mapper pipeline to act on to data.data (array-like of shape (n_samples, n_features)) – Data used to generate the Mapper graph. Can be a pandas dataframe.
layout (None, str or callable, optional, default:
'kamada-kawai'
) – Layout algorithm for the graph. Can be any accepted value for thelayout
parameter in thelayout
method ofigraph.Graph
. 1layout_dim (int, default:
2
) – The number of dimensions for the layout. Can be 2 or 3.color_variable (object or None, optional, default:
None
) –Specifies which quantity is to be used for node coloring.
If a numpy ndarray or pandas dataframe, color_variable must have the same length as data and is interpreted as a quantity of interest according to which node of the Mapper graph is to be colored (see node_color_statistic).
If
None
then equivalent to passing data.If an object implementing
transform
orfit_transform
, e.g. a scikit-learn estimator or pipeline, it is applied to data to generate the quantity of interest.If an index or string, or list of indices / strings, equivalent to selecting a column or subset of columns from data.
node_color_statistic (None, callable, or ndarray of shape (n_nodes,) or (n_nodes, 1), optional, default:
None
) – Specifies how to determine the colors of each node. If a numpy array, it must have the same length as the number of nodes in the Mapper graph, and its values are used directly for node coloring, ignoring color_variable. Otherwise, it can be a callable object which is used to obtain a summary statistic, within each Mapper node, of the quantity specified by color_variable. The default valueNone
is equivalent to passingnumpy.mean
.color_by_columns_dropdown (bool, optional, default:
False
) – IfTrue
, a dropdown widget is generated which allows the user to color Mapper nodes according to any column in data.plotly_kwargs (dict, optional, default:
None
) – Keyword arguments to configure the Plotly Figure.clone_pipeline (bool, optional, default:
True
) – IfTrue
, the input pipeline is cloned before computing the Mapper graph to prevent unexpected side effects from in-place parameter updates.
- Returns
fig – Figure representing the Mapper graph with appropriate node colouring and size.
- Return type
plotly.graph_objects.Figure
object
References
- 1
igraph.Graph.layout documentation.