py3plex.visualization package

Submodules

py3plex.visualization.benchmark_visualizations module

py3plex.visualization.benchmark_visualizations.generic_grouping(fname, score_name, threshold=1, percentages=True)
py3plex.visualization.benchmark_visualizations.plot_core_macro(fname)

A very simple visualization of the results..

py3plex.visualization.benchmark_visualizations.plot_core_macro_box(fname)
py3plex.visualization.benchmark_visualizations.plot_core_macro_gg(fnamex)
py3plex.visualization.benchmark_visualizations.plot_core_micro(fname)

A very simple visualization of the results..

py3plex.visualization.benchmark_visualizations.plot_core_micro_gg(fnamex)
py3plex.visualization.benchmark_visualizations.plot_core_micro_grid(fname)
py3plex.visualization.benchmark_visualizations.plot_core_time(fnamex)
py3plex.visualization.benchmark_visualizations.plot_core_time_gg(fname)
py3plex.visualization.benchmark_visualizations.plot_core_variability(fname)
py3plex.visualization.benchmark_visualizations.plot_critical_distance(fname, num_algo=14)
py3plex.visualization.benchmark_visualizations.plot_mean_times(fn)
py3plex.visualization.benchmark_visualizations.plot_robustness(infile)
py3plex.visualization.benchmark_visualizations.table_to_latex(fname, outfolder='../final_results/tables/', threshold=1)

py3plex.visualization.bezier module

py3plex.visualization.bezier.bezier_calculate_dfy(mp_y, path_height, x0, midpoint_x, x1, y0, y1, dfx, mode='upper')
py3plex.visualization.bezier.draw_bezier(total_size, p1, p2, mode='quadratic', inversion=False, path_height=2, linemode='both', resolution=0.1)

py3plex.visualization.colors module

py3plex.visualization.colors.RGB_to_hex(RGB)

[255,255,255] -> “#FFFFFF”

py3plex.visualization.colors.color_dict(gradient)

Takes in a list of RGB sub-lists and returns dictionary of colors in RGB and hex form for use in a graphing function defined later on

py3plex.visualization.colors.hex_to_RGB(hex)

“#FFFFFF” -> [255,255,255]

py3plex.visualization.colors.linear_gradient(start_hex, finish_hex='#FFFFFF', n=10)

returns a gradient list of (n) colors between two hex colors. start_hex and finish_hex should be the full six-digit color string, inlcuding the number sign (“#FFFFFF”)

py3plex.visualization.drawing_machinery module

py3plex.visualization.drawing_machinery.draw(G, pos=None, ax=None, **kwds)

Draw the graph G with Matplotlib.

Draw the graph as a simple representation with no node labels or edge labels and using the full Matplotlib figure area and no axis labels by default. See draw_networkx() for more full-featured drawing that allows title, axis labels etc.

Parameters
  • G (graph) – A networkx graph

  • pos (dictionary, optional) – A dictionary with nodes as keys and positions as values. If not specified a spring layout positioning will be computed. See networkx.drawing.layout for functions that compute node positions.

  • ax (Matplotlib Axes object, optional) – Draw the graph in specified Matplotlib axes.

  • kwds (optional keywords) – See networkx.draw_networkx() for a description of optional keywords.

Examples

>>> G = nx.dodecahedral_graph()
>>> nx.draw(G)
>>> nx.draw(G, pos=nx.spring_layout(G))  # use spring layout

Notes

This function has the same name as pylab.draw and pyplot.draw so beware when using

>>> from networkx import *

since you might overwrite the pylab.draw function.

With pyplot use

>>> import matplotlib.pyplot as plt
>>> import networkx as nx
>>> G = nx.dodecahedral_graph()
>>> nx.draw(G)  # networkx draw()
>>> plt.draw()  # pyplot draw()

Also see the NetworkX drawing examples at https://networkx.github.io/documentation/latest/auto_examples/index.html

py3plex.visualization.drawing_machinery.draw_networkx(G, pos=None, arrows=True, with_labels=True, **kwds)

Draw the graph G using Matplotlib.

Draw the graph with Matplotlib with options for node positions, labeling, titles, and many other drawing features. See draw() for simple drawing without labels or axes.

Parameters
  • G (graph) – A networkx graph

  • pos (dictionary, optional) – A dictionary with nodes as keys and positions as values. If not specified a spring layout positioning will be computed. See networkx.drawing.layout for functions that compute node positions.

  • arrows (bool, optional (default=True)) – For directed graphs, if True draw arrowheads. Note: Arrows will be the same color as edges.

  • arrowstyle (str, optional (default=’-|>’)) – For directed graphs, choose the style of the arrowsheads. See :py:class: matplotlib.patches.ArrowStyle for more options.

  • arrowsize (int, optional (default=10)) – For directed graphs, choose the size of the arrow head head’s length and width. See :py:class: matplotlib.patches.FancyArrowPatch for attribute mutation_scale for more info.

  • with_labels (bool, optional (default=True)) – Set to True to draw labels on the nodes.

  • ax (Matplotlib Axes object, optional) – Draw the graph in the specified Matplotlib axes.

  • nodelist (list, optional (default G.nodes())) – Draw only specified nodes

  • edgelist (list, optional (default=G.edges())) – Draw only specified edges

  • node_size (scalar or array, optional (default=300)) – Size of nodes. If an array is specified it must be the same length as nodelist.

  • node_color (color string, or array of floats, (default='r')) – Node color. Can be a single color format string, or a sequence of colors with the same length as nodelist. If numeric values are specified they will be mapped to colors using the cmap and vmin,vmax parameters. See matplotlib.scatter for more details.

  • node_shape (string, optional (default='o')) – The shape of the node. Specification is as matplotlib.scatter marker, one of ‘so^>v<dph8’.

  • alpha (float, optional (default=1.0)) – The node and edge transparency

  • cmap (Matplotlib colormap, optional (default=None)) – Colormap for mapping intensities of nodes

  • vmin,vmax (float, optional (default=None)) – Minimum and maximum for node colormap scaling

  • linewidths ([None | scalar | sequence]) – Line width of symbol border (default =1.0)

  • width (float, optional (default=1.0)) – Line width of edges

  • edge_color (color string, or array of floats (default='r')) – Edge color. Can be a single color format string, or a sequence of colors with the same length as edgelist. If numeric values are specified they will be mapped to colors using the edge_cmap and edge_vmin,edge_vmax parameters.

  • edge_cmap (Matplotlib colormap, optional (default=None)) – Colormap for mapping intensities of edges

  • edge_vmin,edge_vmax (floats, optional (default=None)) – Minimum and maximum for edge colormap scaling

  • style (string, optional (default='solid')) – Edge line style (solid|dashed|dotted,dashdot)

  • labels (dictionary, optional (default=None)) – Node labels in a dictionary keyed by node of text labels

  • font_size (int, optional (default=12)) – Font size for text labels

  • font_color (string, optional (default='k' black)) – Font color string

  • font_weight (string, optional (default='normal')) – Font weight

  • font_family (string, optional (default='sans-serif')) – Font family

  • label (string, optional) – Label for graph legend

Notes

For directed graphs, arrows are drawn at the head end. Arrows can be turned off with keyword arrows=False.

Examples

>>> G = nx.dodecahedral_graph()
>>> nx.draw(G)
>>> nx.draw(G, pos=nx.spring_layout(G))  # use spring layout
>>> import matplotlib.pyplot as plt
>>> limits = plt.axis('off')  # turn of axis

Also see the NetworkX drawing examples at https://networkx.github.io/documentation/latest/auto_examples/index.html

py3plex.visualization.drawing_machinery.draw_networkx_nodes(G, pos, nodelist=None, node_size=300, node_color='r', node_shape='o', alpha=1.0, cmap=None, vmin=None, vmax=None, ax=None, linewidths=None, edgecolors=None, label=None, **kwds)

Draw the nodes of the graph G.

This draws only the nodes of the graph G.

Parameters
  • G (graph) – A networkx graph

  • pos (dictionary) – A dictionary with nodes as keys and positions as values. Positions should be sequences of length 2.

  • ax (Matplotlib Axes object, optional) – Draw the graph in the specified Matplotlib axes.

  • nodelist (list, optional) – Draw only specified nodes (default G.nodes())

  • node_size (scalar or array) – Size of nodes (default=300). If an array is specified it must be the same length as nodelist.

  • node_color (color string, or array of floats) – Node color. Can be a single color format string (default=’r’), or a sequence of colors with the same length as nodelist. If numeric values are specified they will be mapped to colors using the cmap and vmin,vmax parameters. See matplotlib.scatter for more details.

  • node_shape (string) – The shape of the node. Specification is as matplotlib.scatter marker, one of ‘so^>v<dph8’ (default=’o’).

  • alpha (float or array of floats) – The node transparency. This can be a single alpha value (default=1.0), in which case it will be applied to all the nodes of color. Otherwise, if it is an array, the elements of alpha will be applied to the colors in order (cycling through alpha multiple times if necessary).

  • cmap (Matplotlib colormap) – Colormap for mapping intensities of nodes (default=None)

  • vmin,vmax (floats) – Minimum and maximum for node colormap scaling (default=None)

  • linewidths ([None | scalar | sequence]) – Line width of symbol border (default =1.0)

  • edgecolors ([None | scalar | sequence]) – Colors of node borders (default = node_color)

  • label ([None| string]) – Label for legend

Returns

PathCollection of the nodes.

Return type

matplotlib.collections.PathCollection

Examples

>>> G = nx.dodecahedral_graph()
>>> nodes = nx.draw_networkx_nodes(G, pos=nx.spring_layout(G))

Also see the NetworkX drawing examples at https://networkx.github.io/documentation/latest/auto_examples/index.html

py3plex.visualization.drawing_machinery.draw_networkx_edges(G, pos, edgelist=None, width=1.0, edge_color='k', style='solid', alpha=1.0, arrowstyle='-|>', arrowsize=10, edge_cmap=None, edge_vmin=None, edge_vmax=None, ax=None, arrows=True, label=None, node_size=300, nodelist=None, node_shape='o', **kwds)

Draw the edges of the graph G.

This draws only the edges of the graph G.

Parameters
  • G (graph) – A networkx graph

  • pos (dictionary) – A dictionary with nodes as keys and positions as values. Positions should be sequences of length 2.

  • edgelist (collection of edge tuples) – Draw only specified edges(default=G.edges())

  • width (float, or array of floats) – Line width of edges (default=1.0)

  • edge_color (color string, or array of floats) – Edge color. Can be a single color format string (default=’r’), or a sequence of colors with the same length as edgelist. If numeric values are specified they will be mapped to colors using the edge_cmap and edge_vmin,edge_vmax parameters.

  • style (string) – Edge line style (default=’solid’) (solid|dashed|dotted,dashdot)

  • alpha (float) – The edge transparency (default=1.0)

  • cmap (edge) – Colormap for mapping intensities of edges (default=None)

  • edge_vmin,edge_vmax (floats) – Minimum and maximum for edge colormap scaling (default=None)

  • ax (Matplotlib Axes object, optional) – Draw the graph in the specified Matplotlib axes.

  • arrows (bool, optional (default=True)) – For directed graphs, if True draw arrowheads. Note: Arrows will be the same color as edges.

  • arrowstyle (str, optional (default=’-|>’)) – For directed graphs, choose the style of the arrow heads. See :py:class: matplotlib.patches.ArrowStyle for more options.

  • arrowsize (int, optional (default=10)) – For directed graphs, choose the size of the arrow head head’s length and width. See :py:class: matplotlib.patches.FancyArrowPatch for attribute mutation_scale for more info.

  • label ([None| string]) – Label for legend

Returns

  • matplotlib.collection.LineCollectionLineCollection of the edges

  • list of matplotlib.patches.FancyArrowPatchFancyArrowPatch instances of the directed edges

  • Depending whether the drawing includes arrows or not.

Notes

For directed graphs, arrows are drawn at the head end. Arrows can be turned off with keyword arrows=False. Be sure to include node_size as a keyword argument; arrows are drawn considering the size of nodes.

Examples

>>> G = nx.dodecahedral_graph()
>>> edges = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))
>>> G = nx.DiGraph()
>>> G.add_edges_from([(1, 2), (1, 3), (2, 3)])
>>> arcs = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))
>>> alphas = [0.3, 0.4, 0.5]
>>> for i, arc in enumerate(arcs):  # change alpha values of arcs
...     arc.set_alpha(alphas[i])

Also see the NetworkX drawing examples at https://networkx.github.io/documentation/latest/auto_examples/index.html

py3plex.visualization.drawing_machinery.draw_networkx_labels(G, pos, labels=None, font_size=1, font_color='k', font_family='sans-serif', font_weight='normal', alpha=1.0, bbox=None, ax=None, **kwds)

Draw node labels on the graph G.

Parameters
  • G (graph) – A networkx graph

  • pos (dictionary) – A dictionary with nodes as keys and positions as values. Positions should be sequences of length 2.

  • labels (dictionary, optional (default=None)) – Node labels in a dictionary keyed by node of text labels Node-keys in labels should appear as keys in pos. If needed use: {n:lab for n,lab in labels.items() if n in pos}

  • font_size (int) – Font size for text labels (default=12)

  • font_color (string) – Font color string (default=’k’ black)

  • font_family (string) – Font family (default=’sans-serif’)

  • font_weight (string) – Font weight (default=’normal’)

  • alpha (float) – The text transparency (default=1.0)

  • ax (Matplotlib Axes object, optional) – Draw the graph in the specified Matplotlib axes.

Returns

dict of labels keyed on the nodes

Return type

dict

Examples

>>> G = nx.dodecahedral_graph()
>>> labels = nx.draw_networkx_labels(G, pos=nx.spring_layout(G))

Also see the NetworkX drawing examples at https://networkx.github.io/documentation/latest/auto_examples/index.html

py3plex.visualization.drawing_machinery.draw_networkx_edge_labels(G, pos, edge_labels=None, label_pos=0.5, font_size=10, font_color='k', font_family='sans-serif', font_weight='normal', alpha=1.0, bbox=None, ax=None, rotate=True, **kwds)

Draw edge labels.

Parameters
  • G (graph) – A networkx graph

  • pos (dictionary) – A dictionary with nodes as keys and positions as values. Positions should be sequences of length 2.

  • ax (Matplotlib Axes object, optional) – Draw the graph in the specified Matplotlib axes.

  • alpha (float) – The text transparency (default=1.0)

  • edge_labels (dictionary) – Edge labels in a dictionary keyed by edge two-tuple of text labels (default=None). Only labels for the keys in the dictionary are drawn.

  • label_pos (float) – Position of edge label along edge (0=head, 0.5=center, 1=tail)

  • font_size (int) – Font size for text labels (default=12)

  • font_color (string) – Font color string (default=’k’ black)

  • font_weight (string) – Font weight (default=’normal’)

  • font_family (string) – Font family (default=’sans-serif’)

  • bbox (Matplotlib bbox) – Specify text box shape and colors.

  • clip_on (bool) – Turn on clipping at axis boundaries (default=True)

Returns

dict of labels keyed on the edges

Return type

dict

Examples

>>> G = nx.dodecahedral_graph()
>>> edge_labels = nx.draw_networkx_edge_labels(G, pos=nx.spring_layout(G))

Also see the NetworkX drawing examples at https://networkx.github.io/documentation/latest/auto_examples/index.html

py3plex.visualization.drawing_machinery.draw_circular(G, **kwargs)

Draw the graph G with a circular layout.

Parameters
  • G (graph) – A networkx graph

  • kwargs (optional keywords) – See networkx.draw_networkx() for a description of optional keywords, with the exception of the pos parameter which is not used by this function.

py3plex.visualization.drawing_machinery.draw_kamada_kawai(G, **kwargs)

Draw the graph G with a Kamada-Kawai force-directed layout.

Parameters
  • G (graph) – A networkx graph

  • kwargs (optional keywords) – See networkx.draw_networkx() for a description of optional keywords, with the exception of the pos parameter which is not used by this function.

py3plex.visualization.drawing_machinery.draw_random(G, **kwargs)

Draw the graph G with a random layout.

Parameters
  • G (graph) – A networkx graph

  • kwargs (optional keywords) – See networkx.draw_networkx() for a description of optional keywords, with the exception of the pos parameter which is not used by this function.

py3plex.visualization.drawing_machinery.draw_spectral(G, **kwargs)

Draw the graph G with a spectral layout.

Parameters
  • G (graph) – A networkx graph

  • kwargs (optional keywords) – See networkx.draw_networkx() for a description of optional keywords, with the exception of the pos parameter which is not used by this function.

py3plex.visualization.drawing_machinery.draw_spring(G, **kwargs)

Draw the graph G with a spring layout.

Parameters
  • G (graph) – A networkx graph

  • kwargs (optional keywords) – See networkx.draw_networkx() for a description of optional keywords, with the exception of the pos parameter which is not used by this function.

py3plex.visualization.drawing_machinery.draw_shell(G, **kwargs)

Draw networkx graph with shell layout.

Parameters
  • G (graph) – A networkx graph

  • kwargs (optional keywords) – See networkx.draw_networkx() for a description of optional keywords, with the exception of the pos parameter which is not used by this function.

py3plex.visualization.layout_algorithms module

py3plex.visualization.layout_algorithms.compute_force_directed_layout(g, layout_parameters=None, verbose=True, gravity=0.2, strongGravityMode=False, barnesHutTheta=1.2, edgeWeightInfluence=1, scalingRatio=2.0, forceImport=True)
py3plex.visualization.layout_algorithms.compute_random_layout(g)

py3plex.visualization.misc_tools module

py3plex.visualization.multilayer module

py3plex.visualization.multilayer.draw_multiedges(network_list, multi_edge_tuple, input_type='nodes', linepoints='-.', alphachannel=0.3, linecolor='black', curve_height=1, style='curve2_bezier', linewidth=1, invert=False, linmod='both', resolution=0.001)
py3plex.visualization.multilayer.draw_multilayer_default(network_list, display=True, node_size=10, alphalevel=0.13, rectanglex=1, rectangley=1, background_shape='circle', background_color='rainbow', networks_color='rainbow', labels=False, arrowsize=0.5, label_position=1, verbose=False, remove_isolated_nodes=False, axis=None, edge_size=1, node_labels=False, node_font_size=5, scale_by_size=False)

Core multilayer drawing method

Args: network_list (list): a list of networks display (bool): Whether to display or not (directly) node_size (int): size of the nodes alphalevel (float): transparency level rectanglex (float): size of rectangles (background) (horizontal part) rectangley (float): size of vertical parts of rectangles background_shape (string): Background shape, either circle or rectangle background_color (string): Background color networks_color (string): Color of individual networks labels (bool): Display labels? arrowsize (float): Sizes of individual arrows label_position (int): position of labels (diagonal right) verbose (bool): Verbose printout? remove_isolated_nodes (bool): Remove isolated nodes? axis (bools): axis are displayed edge_size (float): Size of edges node_labels (bool): Display node labels? node_font_size (int): Size of the font scale_by_size (bool): Scale nodes according to their degrees?

Returns

None

py3plex.visualization.multilayer.generate_random_multiedges(network_list, random_edges, style='line', linepoints='-.', upper_first=2, lower_first=0, lower_second=2, inverse_tag=False, pheight=1)
py3plex.visualization.multilayer.generate_random_networks(number_of_networks)
py3plex.visualization.multilayer.hairball_plot(g, color_list=None, display=False, node_size=1, text_color='black', node_sizes=None, layout_parameters=None, legend=None, scale_by_size=True, layout_algorithm='force', edge_width=0.01, alpha_channel=0.5, labels=None, draw=True, label_font_size=2)

A method for drawing force-directed plots Args: network (networkx): A network to be visualized color_list (list): A list of colors for nodes node_size (float): Size of nodes layout_parameters (dict): A dictionary of label parameters legend (bool): Display legend? scale_by_size (bool): Rescale nodes? layout_algorithm (string): What type of layout algorithm is to be used? edge_width (float): Width of edges alpha_channel (float): Transparency level. labels (bool): Display labels? label_font_size (int): Sizes of labels :returns: None

py3plex.visualization.multilayer.interactive_hairball_plot(G, nsizes, final_color_mapping, pos, colorscale='Rainbow')
py3plex.visualization.multilayer.onclick(event)
py3plex.visualization.multilayer.supra_adjacency_matrix_plot(matrix, display=False)

py3plex.visualization.polyfit module

py3plex.visualization.polyfit.draw_order3(networks, p1, p2)
py3plex.visualization.polyfit.draw_piramidal(networks, p1, p2)

Module contents