uesgraphs.visuals

This module contains visualization tools for uesgraphs

Functions

set_up_logger(name[, log_dir, level])

Classes

Visuals(uesgraph[, log_level])

Visualizes a uesgraph by networkX graph drawing

uesgraphs.visuals.set_up_logger(name, log_dir=None, level=40)[source]
class uesgraphs.visuals.Visuals(uesgraph, log_level=10)[source]

Visualizes a uesgraph by networkX graph drawing

Parameters:

uesgraph (uesgraphs.uesgraph.UESGraph object) – The visualization output will be following the graph layout specified in the input uesgraph

__init__(uesgraph, log_level=10)[source]

Constructor for Visuals

create_plot_simple(ax, scaling_factor=0.5)[source]

Creates a very simple plot setup for fast performance

Parameters:
  • ax (maplotlib ax object) –

  • scaling_factor (float) – Factor that scales the sized of node dots in the plot relative to the edge widths

Returns:

ax

Return type:

maplotlib ax object

create_plot(ax, labels=None, show_diameters=False, show_mass_flows=False, show_press_flows=False, show_press_drop_flows=False, show_velocity=False, show_temperature_drop=False, label_size=7, edge_markers=[], node_markers=[], add_diameter=False, add_edge_temperatures=False, add_edge_flows=False, add_edge_pressures=False, add_edge_pressure_drop=False, add_edge_velocity=False, add_temperature_drop=False, add_temperature_diff=False, directions=False, scaling_factor=1.5, scaling_factor_diameter=5, minmaxtemp=False, minmaxmflow=False, minmaxmpress=False, minmaxmpressdrop=False, minmaxmvelocity=False, minmaxmtempdrop=False, generic_intensive_size=None, generic_extensive_size=None, minmax=False, zero_alpha=1, cmap='viridis')[source]

Creates the plot setup, that can be shown or saved to file

Parameters:
  • ax (maplotlib ax object) –

  • labels (str) – If set to ‘street’, node numbers of street nodes are shown in plot

  • show_diameters (boolean) – True if edges of heating networks should show the relative diameter of the pipe, False if not

  • show_mass_flows (boolean) – True if edges of heating networks should show the mass flow rate through the pipe, False if not

  • show_press_flows (boolean) – True if edges of heating networks should show the pressure through the pipe, False if not

  • show_press_drop_flows (boolean) – True if edges of heating networks should show the pressure drop through the pipe, False if not

  • label_size (int) – Fontsize for optional labels

  • edge_markers (list) – A list of edges that should be marked in the plot

  • node_markers (list) – A list of nodes that should be marked in the plot

  • add_edge_temperatures (boolean) – Plots edge temperatures on top of plot if True

  • add_edge_flows (boolean) – Plots edge width according to flow rates in the networks if True

  • add_edge_pressures (boolean) – Plots edge pressure on top of plot if True

  • add_edge_pressure_drop (boolean) – Plots edge pressure drop on top of plot if True

  • add_edge_electricity (boolean) – Plots edge electricity on top of plot if True

  • directions (boolean) – Plots arrows for flow directions if True; If add_edge_flows is False, these arrows will show the initial assumed flow direction. If add_edge_flows is True, the arrows show the calculated flow direction.

  • scaling_factor (float) – Factor that scales the sized of node dots in the plot relative to the edge widths

  • scaling_factor_diameter (float) – Factor that scales the width of lines for show_diameters = True

  • generic_intensive_size (str) – If set to a string, the edges will be colored according to the values of the attribute with the given string

  • generic_extensive_size (str) – If set to a string, the edges will be colored according to the values of the attribute with the given string

  • minmax (array) – Contains the minimum and maximum values for the generic size in format [min, max]

  • zero_alpha (float) – Alpha value to paint certain edges transparent. Look at docstring of paint_edges_extensive_sizes for more information

  • cmap (str, optional) – Name of the colormap to use for visualization (default=’viridis’). Common options include ‘viridis’, ‘coolwarm’, ‘RdYlGn’, ‘plasma’, ‘Blues’. For temperature data, ‘coolwarm’ or ‘RdYlGn’ provide intuitive red=hot, blue=cold color semantics.

Returns:

ax

Return type:

maplotlib ax object

create_plot_3d(ax, z_attrib='pressure', show_flow=False, angle=110, label_size=20)[source]

Creates the plot setup for a 3d view

Parameters:
  • ax (maplotlib ax object) –

  • z_attrib (str) – Keyword to control which attribute of nodes will be used for the z-coordinate

  • show_flow (boolean) – Varies linewidth of the edges if True

  • angle (float) – View angle for 3d plot

  • label_size (int) – Fontsize for labels

Returns:

ax

Return type:

maplotlib ax object

show_network(save_as=None, show_plot=True, labels=None, show_diameters=False, show_mass_flows=False, show_press_flows=False, show_press_drop_flows=False, show_velocity=False, show_temperature_drop=False, label_size=7, edge_markers=[], node_markers=[], add_diameter=False, add_edge_temperatures=False, add_temperature_drop=False, add_temperature_diff=False, add_edge_flows=False, add_edge_pressures=False, add_edge_pressure_drop=False, add_edge_velocity=False, directions=False, scaling_factor=1.5, scaling_factor_diameter=5, simple=False, dpi=150, minmaxtemp=False, minmaxmflow=False, minmaxmpress=False, minmaxmpressdrop=False, minmaxmvelocity=False, minmaxmtempdrop=False, timestamp=False, generic_intensive_size=None, generic_extensive_size=None, minmax=None, ylabel=None, zero_alpha=1, cmap='viridis')[source]

Shows a plot of the network

Parameters:
  • save_as (str) – optional parameter, string denoting full path and file name + extension for saving the plot

  • show_plot (boolean) – True if the plot should be shown in the current Python instance, False if not

  • labels (str) – If set to ‘street’, node numbers of street nodes are shown in plot

  • show_diameters (boolean) – True if edges of heating networks should show the relative diameter of the pipe, False if not

  • show_mass_flows (boolean) – True if edges of heating networks should show the mass flow rate through the pipe, False if not

  • show_press_flows (boolean) – True if edges of heating networks should show the pressure through the pipe, False if not

  • show_press_drop_flows (boolean) – True if edges of heating networks should show the pressure drop through the pipe, False if not

  • label_size (int) – Fontsize for optional labels

  • edge_markers (list) – A list of edges that should be marked in the plot

  • node_markers (list) – A list of nodes that should be marked in the plot

  • add_edge_temperatures (boolean) – Plots edge temperatures on top of plot if True

  • add_edge_flows (boolean) – Plots edge width according to flow rates in the networks if True

  • add_edge_pressures (boolean) – Plots edge pressure on top of plot if True

  • add_edge_pressure_drop (boolean) – Plots edge pressure drop on top of plot if True

  • directions (boolean) – Plots arrows for flow directions if True; If add_edge_flows is False, these arrows will show the initial assumed flow direction. If add_edge_flows is True, the arrows show the calculated flow direction.

  • scaling_factor (float) – Factor that scales the sized of node dots in the plot relative to the edge widths

  • scaling_factor_diameter (float) – Factor that scales the width of lines

  • simple (boolean) – For very large uesgraphs, the standard plotting may take too long (hours…). In these cases, simple=True gives faster results

  • dpi (int) – Integer to overwrite the standard resolution of 150 dpi

  • minmaxtemp (array) – Array with minimum and maximum temperature value for the scaling of the plot. If not set the values will be calculated automatically

  • minmaxmflow (array) – Array with minimum and maximum temperature value for the scaling of the plot. If not set the values will be calculated automatically

  • minmaxmpress (array) – Array with minimum and maximum pressure value for the scaling of the plot. If not set the values will be calculated automatically

  • minmaxmpressdrop (array) – Array with minimum and maximum pressure drop value for the scaling of the plot. If not set the values will be calculated automatically

  • timestamp (datetime) – prints the actual timestamp on the plot

  • generic_intensive_size (str) – If set to a string, the edges will be colored according to the values of the attribute with the given string

  • generic_extensive_size (str) – If set to a string, the edges will be colored according to the values of the attribute with the given string

  • minmax (array) – Contains the minimum and maximum values for the generic size in format [min, max]

  • ylabel (str) – Label for the color scale when plotting generic size

  • zero_alpha (float) – Alpha value to paint certain edges transparent. Look at docstring of paint_edges_extensive_sizes for more information

  • cmap (str, optional) – Name of the colormap to use for visualization (default=’viridis’). Common options include ‘viridis’, ‘coolwarm’, ‘RdYlGn’, ‘plasma’, ‘Blues’. For temperature data, ‘coolwarm’ or ‘RdYlGn’ provide intuitive red=hot, blue=cold color semantics.

Returns:

fig

Return type:

matplotlib.figure.Figure

show_3d(save_as=None, show_plot=True, show_flow=False, z_attrib='pressure', angle=110, label_size=20)[source]

Shows an explosion plot of stacked networks in 3d view

Parameters:
  • save_as (str) – optional parameter, string denoting full path and file name + extension for saving the plot

  • show_plot (boolean) – True if the plot should be shown in the current Python instance, False if not

  • show_flow (boolean) – Varies linewidth of the edges if True

  • z_attrib (str) – Keyword to control which attribute of nodes will be used for the z-coordinate

  • angle (float) – View angle for 3d plot

  • label_size (int) – Fontsize for optional labels

Returns:

fig

Return type:

matplotlib.figure.Figure

network_explosion(save_as=None, show_plot=True, angle=250, networks=['all'], scaling_factor=1.5, dotted_lines=True)[source]

Shows a plot of the network in 3d view

Parameters:
  • save_as (str) – optional parameter, string denoting full path and file name + extension for saving the plot

  • show_plot (boolean) – True if the plot should be shown in the current Python instance, False if not

  • angle (float) – View angle for 3d plot

  • networks (list) – Instead of [‘all’], the networks list can specify which networks should be plotted. Accepted items are {‘heating’, ‘cooling’, ‘electricity’, ‘gas’, ‘others’}

  • scaling_factor (float) – Factor that scales the sized of node dots in the plot relative to the edge widths

  • dotted_lines (boolean) – Optional dotted lines between different levels of network explosion if set to True

Returns:

fig

Return type:

matplotlib.figure.Figure