This tutorial shows you how to make interactive plots of pandapower networks using plotly (https://plot.ly/python/). The best way to get started is to get familiar with 3 built-in plots that correspond to:
The following sample plots are with mv_oberrhein network from the pandapower.networks package:
from pandapower.plotting.plotly import simple_plotly
from pandapower.networks import mv_oberrhein
from pandapower import runpp
net = mv_oberrhein()
runpp(net)
A simple network plot wich labels as separate trace all network buses, lines, transformers and external grid. Try some of the fancy plotly features from the upper-right corner:
simple_plotly(net)
Plots a network colored and layered according to voltage levels.
from pandapower.plotting.plotly import vlevel_plotly
vlevel_plotly(net)
from pandapower.networks import create_cigre_network_hv
net = create_cigre_network_hv()
runpp(net)
vlevel_plotly(net)
Results from res_bus
, res_line
and res_trafo
can be effectively displayed using pf_res_plolty
.
Buses colored according to resulting voltage magnitude using colormap in range $[0.9,1.1]$.
Lines and trafos are colored according to resulting loading using colormap in range $[0,100]$.
Positioning a cursor over a bus or line-breaks shows more details about each element.
from pandapower.plotting.plotly import pf_res_plotly
pf_res_plotly(net)
Interactive plots are built to share some general plotting features with static plots using matplotlib.
net = mv_oberrhein()
runpp(net)
# delete the geocoordinates
net.bus_geodata.drop(net.bus_geodata.index, inplace=True)
net.line_geodata.drop(net.line_geodata.index, inplace=True)
simple_plotly(net)
Aspect ratio (aspectratio
) - default aspect ratio of a figure is set to 'auto'
which means keeping aspect ratio proportional to geodata. If aspectratio=False
figure will be stretch according to window size.
net.bus_geodata.drop(net.bus_geodata.index, inplace=True)
net.line_geodata.drop(net.line_geodata.index, inplace=True)
pf_res_plotly(net, aspectratio=(1.3,1))
Figure Size (figsize
) is by default set to 1 and it is used only to multiply total plot size, thus real figure size figsize=aspectratio*figsize
net = mv_oberrhein()
simple_plotly(net, aspectratio=(2,1), figsize=0.5)
More tutorials about interactive plots using ploltly: