commutazzio.plot package

Submodules

commutazzio.plot.cl4_point_cloud_visualizers module

class commutazzio.plot.cl4_point_cloud_visualizers.CechCL4Viz(points: array, deletion_list: array)

Bases: object

visualize the 2D configuration of CL(4)-filtration of simplicial complexes formed from a point cloud in 2D use the Cech Complex

render_all(radii: list, xrange: list = [-5, 5], yrange: list = [0, 5], subtitles: list[str] | None = None, width=180, height=220)
class commutazzio.plot.cl4_point_cloud_visualizers.ChroAlphaCL4Viz(points: array, deletion_list: array)

Bases: object

visualize the 2D configuration of CL(4)-filtration of simplicial complexes formed from a point cloud in 2D use the Chromatic Alpha Complex.

get_edges(radius)

return all edges with filtration value equal or less than radius notice that filtration value in an alpha complex is squared.

get_n_simplices(n, radius)

return all n-simplices with filtration value equal or less than radius notice that filtration value in an alpha complex is squared.

get_tetrahedra(radius)

return all tetrahedra with filtration value equal or less than radius notice that filtration value in an alpha complex is squared.

get_triangles(radius)

return all triangles with filtration value equal or less than radius notice that filtration value in an alpha complex is squared.

plot_edges(radius, layer)

plot all edges with filtration value not greater than radius

plot_points(layer)

Plot the point cloud.

plot_tetrathedron(tetrahedron)
plot_triangle(triangle)
render_all(radii: list, width=170, height=200)
render_sc(radius, layer, width=800, height=800)

Render the simplicial complex.

commutazzio.plot.colors_helper module

commutazzio.plot.colors_helper.get_color(colorscale_name, loc)
commutazzio.plot.colors_helper.get_continuous_color(colorscale, intermed)

Plotly continuous colorscales assign colors to the range [0, 1]. This function computes the intermediate color for any value in that range.

Plotly doesn’t make the colorscales directly accessible in a common format. Some are ready to use:

colorscale = plotly.colors.PLOTLY_SCALES[“Greens”]

Others are just swatches that need to be constructed into a colorscale:

viridis_colors, scale = plotly.colors.convert_colors_to_same_type(plotly.colors.sequential.Viridis) colorscale = plotly.colors.make_colorscale(viridis_colors, scale=scale)

Parameters:
  • colorscale – A plotly continuous colorscale defined with RGB string colors.

  • intermed – value in the range [0, 1]

Returns:

color in rgb string format

Return type:

str

commutazzio.plot.colors_helper.show_named_plotly_colours()

function to display to user the colours to match plotly’s named css colours.

Reference:

#https://community.plotly.com/t/plotly-colours-list/11730/3

Returns:

plotly dataframe with cell colour to match named colour name

commutazzio.plot.plot_engine module

Module for visualizing connected persistence diagrams via complementary triangles plots. This module contains the ComplementaryTrianglesPlot class which provides functionalities for generating and displaying these plots using Plotly.

class commutazzio.plot.plot_engine.ComplementaryTrianglesPlot(cPD: ConnectedPersistenceDiagram | None = None, title=None, convention='[b,d)', **kwargs)

Bases: object

A class for visualizing a connected persistence diagram via a complementary triangles plot. This class supports initialization with either a ConnectedPersistenceDiagram instance or custom data in the form of dictionaries.

Parameters: - cPD (ConnectedPersistenceDiagram, optional): The persistence diagram to be visualized. - title (str, optional): Title of the plot. - convention (str, optional): Convention used for the plot, defaults to “[b,d)”, which means inclusive for birth and exclusive for death. - kwargs: Additional keyword arguments for custom data initialization.

add_line(fig, index, row)

add a line connecting two dots from two PDs respectively

static check_cdn_access()
data_preprocessing_dots()

Add auxiliary columns to dots

data_preprocessing_lines()

Add auxiliary columns to lines

legend_grouping(value)

group the legend by the multiplicity

line_chart()

generate the line chart, connect related generators

static one_legend_in_each_group()

An iterator that yields True if the sent value not in container, else yields False

render()

Generates and returns a Plotly figure that combines scatter and line charts to visualize the connected persistence diagram via a complementary triangles plot.

Returns:
plotly.graph_objects.Figure

A Plotly figure object representing the final plot.

render_and_export_figure(export_mode='full_html', **kwargs)

Render the figure and export it based on the specified mode.

Parameters:
export_modestr

The mode to export the figure. Options are ‘full_html’ or ‘div’.

**kwargsdict

Keyword arguments for the figure rendering and exporting. see https://plotly.com/python/interactive-html-export/ for parameters

Returns:
filepathstr
render_axes(fig, offset)
render_general_layout(fig)
render_legend(fig)
render_ticks(fig)
ribbonise(row)

Expanding a line to a rectangle

scatter_chart()

generate the scatter plot, which is a joint of two one-parameter persistence diagrams

show()

a synonym for render and show

commutazzio.plot.row_visualizer module

class commutazzio.plot.row_visualizer.RowVisualizerChroAlpha(points: array, weight_function: dict)

Bases: object

get_edges(radius)

return all edges with filtration value equal or less than radius notice that filtration value in an alpha complex is squared.

get_n_simplices(n, radius)

return all n-simplices with filtration value equal or less than radius notice that filtration value in an alpha complex is squared.

get_triangles(radius)

return all triangles with filtration value equal or less than radius notice that filtration value in an alpha complex is squared.

plot_edges(radius)

plot all edges with filtration value not greater than radius

plot_points()

Plot the point cloud.

plot_triangle(triangle)
render_all(radii: list, width=330, height=600)
render_sc(radius, width=800, height=800)

Render the simplicial complex.

commutazzio.plot.simplicial_complex_2d module

class commutazzio.plot.simplicial_complex_2d.SC2DViz(points: array, radius_max=inf, sc_type='cech')

Bases: object

Plot the simplicial complex of a 2D point cloud.

CIRCUMFERENCE_COLOR = 'rgba(0,174,239,1)'
CIRCUMFERENCE_WIDTH = 2
DISK_COLOR = 'rgba(0,174,239,0.05)'
EDGE_COLOR = 'rgba(247,148,29,0.9)'
EDGE_WIDTH = 2
EPSILON = 0
NUM_COLS = 3
PAPER_BGCOLOR = 'rgba(0,0,0,0)'
PLOT_BGCOLOR = 'rgba(0,0,0,0)'
POINT_COLOR = 'rgba(0,174,239,1)'
POINT_SIZE = 6
TRIANGLE_COLOR = 'rgba(0,174,239,0.35)'
static add_circle(fig, center, radius)
get_edges(radius)

return all edges with filtration value equal or less than radius notice that filtration value in an alpha complex is squared.

get_n_simplices(n, radius)

return all n-simplices with filtration value equal or less than radius notice that filtration value in an alpha complex is squared.

get_points()
get_triangles(radius)

return all triangles with filtration value equal or less than radius notice that filtration value in an alpha complex is squared.

plot_edges(radius)

plot all edges with filtration value not greater than radius

plot_points()

Plot the point cloud.

plot_triangle(triangle)
plot_triangles(radius)

plot all triangles with filtration value not greater than radius

using this function causes unexpected behaviour when triangles overlap

radii_critical()
render_all(width=330, height=600, with_circles=True)
render_circles(radius)
render_sc(radius, with_circles=True, width=800, height=800)

Render the simplicial complex.

Module contents