Create & Draw Traces

Plotly traces can be created from pandapower networks with the following functions.

Bus Traces

pandapower.plotting.plotly.create_bus_trace(net, buses=None, size=5, patch_type='circle', color='blue', infofunc=None, trace_name='buses', legendgroup=None, cmap=None, cmap_vals=None, cbar_title=None, cmin=None, cmax=None, cpos=1.0, colormap_column='vm_pu')

Creates a plotly trace of pandapower buses.

INPUT:

net (pandapowerNet) - The pandapower network

OPTIONAL:

buses (list, None) - The buses for which the collections are created. If None, all buses in the network are considered.

size (int, 5) - patch size

patch_type (str, “circle”) - patch type, can be

infofunc (pd.Series, None) - hoverinfo for bus elements. Indices should correspond to

the pandapower element indices

trace_name (String, “buses”) - name of the trace which will appear in the legend

color (String, “blue”) - color of buses in the trace

cmap (String, None) - name of a colormap which exists within plotly

(Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis) alternatively a custom discrete colormap can be used

cmap_vals (list, None) - values used for coloring using colormap

cbar_title (String, None) - title for the colorbar

cmin (float, None) - colorbar range minimum

cmax (float, None) - colorbar range maximum

cpos (float, 1.1) - position of the colorbar

colormap_column (str, “vm_pu”) - set color of bus according to this variable

Branch Traces

pandapower.plotting.plotly.create_line_trace(net, lines=None, use_line_geodata=True, respect_switches=False, width=1.0, color='grey', infofunc=None, trace_name='lines', legendgroup=None, cmap=None, cbar_title=None, show_colorbar=True, cmap_vals=None, cmin=None, cmax=None, cpos=1.1)

Creates a plotly trace of pandapower lines.

INPUT:

net (pandapowerNet) - The pandapower network

OPTIONAL:

lines (list, None) - The lines for which the collections are created. If None, all lines in the network are considered.

width (int, 1) - line width

respect_switches (bool, False) - flag for consideration of disconnected lines

infofunc (pd.Series, None) - hoverinfo for line elements. Indices should correspond to

the pandapower element indices

trace_name (String, “lines”) - name of the trace which will appear in the legend

color (String, “grey”) - color of lines in the trace

legendgroup (String, None) - defines groups of layers that will be displayed in a legend e.g. groups according to voltage level (as used in vlevel_plotly)

cmap (String, None) - name of a colormap which exists within plotly if set to True default Jet colormap is used, alternative colormaps : Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis

cmap_vals (list, None) - values used for coloring using colormap

show_colorbar (bool, False) - flag for showing or not corresponding colorbar

cbar_title (String, None) - title for the colorbar

cmin (float, None) - colorbar range minimum

cmax (float, None) - colorbar range maximum

cpos (float, 1.1) - position of the colorbar

pandapower.plotting.plotly.create_trafo_trace(net, trafos=None, color='green', width=5, infofunc=None, cmap=None, trace_name='trafos', cmin=None, cmax=None, cmap_vals=None, use_line_geodata=None)

Creates a plotly trace of pandapower trafos.

INPUT:

net (pandapowerNet) - The pandapower network

OPTIONAL:

trafos (list, None) - The trafos for which the collections are created. If None, all trafos in the network are considered.

width (int, 5) - line width

infofunc (pd.Series, None) - hoverinfo for trafo elements. Indices should correspond

to the pandapower element indices

trace_name (String, “lines”) - name of the trace which will appear in the legend

color (String, “green”) - color of lines in the trace

cmap (bool, False) - name of a colormap which exists within plotly (Greys, YlGnBu,

Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis)

cmap_vals (list, None) - values used for coloring using colormap

cbar_title (String, None) - title for the colorbar

cmin (float, None) - colorbar range minimum

cmax (float, None) - colorbar range maximum

Draw Traces

pandapower.plotting.plotly.draw_traces(traces, on_map=False, map_style='basic', showlegend=True, figsize=1, aspectratio='auto', filename='temp-plot.html')

plots all the traces (which can be created using create_bus_trace(), create_line_trace(), create_trafo_trace()) to PLOTLY (see https://plot.ly/python/)

INPUT:

traces - list of dicts which correspond to plotly traces generated using: create_bus_trace, create_line_trace, create_trafo_trace

OPTIONAL:

on_map (bool, False) - enables using mapbox plot in plotly

map_style (str, ‘basic’) - enables using mapbox plot in plotly

  • ‘streets’

  • ‘bright’

  • ‘light’

  • ‘dark’

  • ‘satellite’

showlegend (bool, ‘True’) - enables legend display

figsize (float, 1) - aspectratio is multiplied by it in order to get final image size

aspectratio (tuple, ‘auto’) - when ‘auto’ it preserves original aspect ratio of the

network geodata any custom aspectration can be given as a tuple, e.g. (1.2, 1)

filename (str, “temp-plot.html”) - plots to a html file called filename

OUTPUT:

figure (graph_objs._figure.Figure) figure object