Above example throws the Error message:
"ValueError: RGBA sequence should have length 3 or 4"
This is due to a typo / shadowing issue in the function 'polygon_patches'. Which can be found in
'pandapower.plotting.patch_makers'
def polygon_patches(node_coords, radius, num_edges, color=None, **kwargs):
"""
... OMITTED ...
"""
if not MATPLOTLIB_INSTALLED:
soft_dependency_error(str(sys._getframe().f_code.co_name)+"()", "matplotlib")
patches = list()
if color is not None:
colors = get_color_list(color, len(node_coords))
for (x, y), col in zip(node_coords, colors):
# TYPO IS HERE should be 'col' not 'color', causes list to be used instead of the elements!
patches.append(RegularPolygon([x, y], numVertices=num_edges, radius=radius, color=color,
**kwargs))
else:
for x, y in node_coords:
patches.append(RegularPolygon([x, y], numVertices=num_edges, radius=radius, **kwargs))
return patches
Fix is simply to write "color=col" in the patches.append line.
Expected Behavior
Expect to be able to individually control the color of each patch by passing a list of colors. This works for the node_patches, for example, but not for polygon_patches.
Bug report checklis
[X] Searched the issues page for similar reports
[X] Read the relevant sections of the documentation
[X] Browse the tutorials and tests for usefull code snippets and examples of use
[X] Reproduced the issue after updating with
pip install --upgrade pandapower
(orgit pull
)[X] Tried basic troubleshooting (if a bug/error) like restarting the interpreter and checking the pythonpath
Reproducible Example
Issue Description and Traceback
Above example throws the Error message: "ValueError: RGBA sequence should have length 3 or 4"
This is due to a typo / shadowing issue in the function 'polygon_patches'. Which can be found in 'pandapower.plotting.patch_makers'
Fix is simply to write "color=col" in the patches.append line.
Expected Behavior
Expect to be able to individually control the color of each patch by passing a list of colors. This works for the node_patches, for example, but not for polygon_patches.
Installed Versions
Python: 3.12.1 Pandapower: 2.13.1
Label