cotengra.plot#

Module Contents#

Functions#

use_default_style(fn)

_return_or_close_fig(fig, return_fig)

plot_trials_alt(self[, y, width, height])

Plot the trials interactively using altair.

plot_scatter(self[, x, y, figsize, return_fig])

plot_trials(self[, y, figsize])

plot_scatter_alt(self[, x, y, color, color_scheme, ...])

Plot the trials total flops vs max size.

tree_to_networkx(tree)

hypergraph_compute_plot_info_G(H, G[, highlight, ...])

Imbue the networkx representation, G, of hypergraph, H with

rotate(xy, theta)

Return a rotated set of points.

span(xy)

Return the vertical span of the points.

massage_pos(pos[, nangles, flatten])

Rotate a position dict's points to cover a small vertical span

get_nice_pos(G[, k, iterations, layout, flatten])

plot_tree(tree[, layout, layout_hypergraph, k, ...])

Plot a contraction tree using matplotlib.

plot_tree_ring(tree, **kwargs)

plot_tree_tent(tree, **kwargs)

plot_tree_span(tree, **kwargs)

tree_to_df(tree)

plot_contractions(tree[, x, y, color, size, ...])

plot_contractions_alt(tree[, x, y, color, size, ...])

slicefinder_to_df(slice_finder[, relative_flops])

plot_slicings(slice_finder[, color_scheme, ...])

plot_slicings_alt(slice_finder[, color_scheme, ...])

plot_hypergraph(H, *[, highlight, centrality, ...])

tree_to_hypernetx(tree[, order])

plot_tree_rubberband(tree[, order, colormap, ...])

Plot a ContractionTree using 'rubberbands' to represent intermediate

Attributes#

cotengra.plot.DEFAULT_DRAW_COLOR = [0.5, 0.5, 0.5]#
cotengra.plot.DEFAULT_STYLE#
cotengra.plot.use_default_style(fn)#
cotengra.plot._return_or_close_fig(fig, return_fig)#
cotengra.plot.plot_trials_alt(self, y=None, width=800, height=300)#

Plot the trials interactively using altair.

cotengra.plot._scatter_labels#
cotengra.plot.plot_scatter(self, x='size', y='flops', figsize=(5, 5), return_fig=False)#
cotengra.plot.plot_trials(self, y='score', figsize=(8, 3), **kwargs)#
cotengra.plot.plot_scatter_alt(self, x='size', y='flops', color='run:Q', color_scheme='purplebluegreen', shape='method:N', width=400, height=400)#

Plot the trials total flops vs max size.

cotengra.plot.tree_to_networkx(tree)#
cotengra.plot.hypergraph_compute_plot_info_G(H, G, highlight=(), node_color=(0.5, 0.5, 0.5, 1.0), edge_color=(0.0, 0.0, 0.0), edge_alpha=1 / 3, colormap='Spectral_r', centrality=False, sliced_inds=())#

Imbue the networkx representation, G, of hypergraph, H with relevant plot information as node and edge attributes.

cotengra.plot.rotate(xy, theta)#

Return a rotated set of points.

cotengra.plot.span(xy)#

Return the vertical span of the points.

cotengra.plot.massage_pos(pos, nangles=12, flatten=False)#

Rotate a position dict’s points to cover a small vertical span

cotengra.plot.get_nice_pos(G, k=0.01, iterations=500, layout=None, flatten=False)#
cotengra.plot.plot_tree(tree, layout='ring', layout_hypergraph=None, k=0.01, iterations=500, span=None, order=None, order_y_pow=1.0, edge_scale=1.0, node_scale=1.0, highlight=(), edge_colormap='GnBu', node_colormap='YlOrRd', edge_max_width=None, node_max_size=None, figsize=(5, 5), return_fig=False, raw_edge_color=None, raw_edge_alpha=None, tree_root_height=True, tree_alpha=0.8, colorbars=True, plot_raw_graph=True, plot_leaf_labels=False, ax=None)#

Plot a contraction tree using matplotlib.

cotengra.plot.plot_tree_ring(tree, **kwargs)#
cotengra.plot.plot_tree_tent(tree, **kwargs)#
cotengra.plot.plot_tree_span(tree, **kwargs)#
cotengra.plot.tree_to_df(tree)#
cotengra.plot.plot_contractions(tree, x='peak-size', y='flops', color='stage', size='scaling', point_opacity=0.8, color_scheme='viridis_r', x_scale='log', y_scale='log', figsize=(6, 4), return_fig=False)#
cotengra.plot.plot_contractions_alt(tree, x='peak-size', y='flops', color='stage', size='scaling', width=400, height=400, point_opacity=0.8, color_scheme='lightmulti', x_scale='log', y_scale='log', color_scale='log', size_scale='linear')#
cotengra.plot.slicefinder_to_df(slice_finder, relative_flops=False)#
cotengra.plot.plot_slicings(slice_finder, color_scheme='RdYlBu_r', relative_flops=False, figsize=(6, 3), point_opacity=0.8, return_fig=False)#
cotengra.plot.plot_slicings_alt(slice_finder, color_scheme='redyellowblue', relative_flops=False)#
cotengra.plot.plot_hypergraph(H, *, highlight=(), centrality='simple', colormap='plasma', layout=None, node_size=None, node_color=(0.5, 0.5, 0.5, 1.0), edge_alpha=1 / 3, edge_style='solid', hyperedge_style='dashed', draw_edge_labels=None, edge_labels_font_size=8, edge_labels_font_family='monospace', iterations=500, ax=None, figsize=(5, 5), return_fig=False)#
cotengra.plot.tree_to_hypernetx(tree, order=None)#
cotengra.plot.plot_tree_rubberband(tree, order=None, colormap='rainbow', with_edge_labels=None, with_node_labels=None, highlight=(), centrality=False, layout=None, node_size=None, node_color=(0.5, 0.5, 0.5, 1.0), edge_alpha=1 / 3, edge_style='solid', hyperedge_style='dashed', draw_edge_labels=None, edge_labels_font_size=8, edge_labels_font_family='monospace', iterations=500, ax=None, figsize=(5, 5), return_fig=False)#

Plot a ContractionTree using ‘rubberbands’ to represent intermediate contractions / subgraphs - requires hypernetx. This can be intuitive for small and planar contractions.