Create Colormaps¶
Discrete¶

pandapower.plotting.
cmap_discrete
(cmap_list)¶ Can be used to create a discrete colormap.
 INPUT:
 cmap_list (list)  list of tuples, where each tuple represents one range. Each tuple has
the form of ((from, to), color).
 OUTPUT:
cmap  matplotlib colormap
norm  matplotlib norm object
 EXAMPLE:
>>> from pandapower.plotting import cmap_discrete, create_line_collection, draw_collections >>> from pandapower.networks import mv_oberrhein >>> net = mv_oberrhein("generation") >>> cmap_list = [((0, 10), "green"), ((10, 30), "yellow"), ((30, 100), "red")] >>> cmap, norm = cmap_discrete(cmap_list) >>> lc = create_line_collection(net, cmap=cmap, norm=norm) >>> draw_collections([lc])
Continuous¶

pandapower.plotting.
cmap_continuous
(cmap_list)¶ Can be used to create a continuous colormap.
 INPUT:
 cmap_list (list)  list of tuples, where each tuple represents one color. Each tuple has
the form of (center, color). The colorbar is a linear segmentation of the colors between the centers.
 OUTPUT:
cmap  matplotlib colormap
norm  matplotlib norm object
 EXAMPLE:
>>> from pandapower.plotting import cmap_continuous, create_bus_collection, draw_collections >>> from pandapower.networks import mv_oberrhein >>> net = mv_oberrhein("generation") >>> cmap_list = [(0.97, "blue"), (1.0, "green"), (1.03, "red")] >>> cmap, norm = cmap_continuous(cmap_list) >>> bc = create_bus_collection(net, size=70, cmap=cmap, norm=norm) >>> draw_collections([bc])
Logarithmic¶

pandapower.plotting.
cmap_logarithmic
(min_value, max_value, colors)¶ Can be used to create a logarithmic colormap. The colormap itself has a linear segmentation of the given colors. The values however will be matched to the colors based on a logarithmic normalization (c.f. matplotlib.colors.LogNorm for more information on how the logarithmic normalization works).
 Please note: There are numerous ways of how a logarithmic scale might
be created, the intermediate values on the scale are created automatically based on the minimum and maximum given values in analogy to the LogNorm. Also, the logarithmic colormap can only be used with at least 3 colors and increasing values which all have to be above 0.
 INPUT:
min_value (float)  the minimum value of the colorbar
max_value (float)  the maximum value for the colorbar
colors (list)  list of colors to be used for the colormap
 OUTPUT:
cmap  matplotlib colormap
norm  matplotlib norm object
 EXAMPLE:
>>> from pandapower.plotting import cmap_logarithmic, create_bus_collection, draw_collections >>> from pandapower.networks import mv_oberrhein >>> net = mv_oberrhein("generation") >>> min_value, max_value = 1.0, 1.03 >>> colors = ["blue", "green", "red"] >>> cmap, norm = cmap_logarithmic(min_value, max_value, colors) >>> bc = create_bus_collection(net, size=70, cmap=cmap, norm=norm) >>> draw_collections([bc])