Open nailend opened 8 months ago
@SabineHaas In case you want to plot graphs with pygraphviz
e.g. BEV component
def draw_graph(energysystem):
# Draw the graph
from oemof.network.graph import create_nx_graph
G = create_nx_graph(energysystem)
# Specify layout and draw the graph
pos = nx.drawing.nx_agraph.graphviz_layout(
G, prog="neato", args="-Gepsilon=0.0001"
)
fig, ax = plt.subplots(figsize=(10, 8))
node_colors = list()
for i in list(G.nodes()):
if "storage" in i:
node_colors.append("royalblue")
elif "BEV-V2G" in i:
node_colors.append("firebrick")
elif "BEV-G2V" in i:
node_colors.append("lightblue")
elif "BEV-inflex" in i:
node_colors.append("darkviolet")
elif "excess" in i:
node_colors.append("green")
elif "shortage" in i:
node_colors.append("yellow")
elif "load" in i:
node_colors.append("orange")
elif "wind" in i:
node_colors.append("pink")
elif "bus" in i:
node_colors.append("grey")
else:
node_colors.append("violet")
nx.draw(
G,
pos,
# **options,
with_labels=True,
node_size=3000,
# node_color='lightblue',
font_size=10,
font_weight="bold",
node_color=node_colors,
# node_color=["red", "blue", "green", "yellow", "orange"],
)
labels = nx.get_edge_attributes(G, "weight")
nx.draw_networkx_edge_labels(G, pos=pos, edge_labels=labels)
# Customize the plot as needed
ax.set_title("OEMOF Energy System Graph")
# Show the plot
plt.show()
Install this:
sudo apt-get install python3-dev graphviz libgraphviz-dev pkg-config
and thenpip install pygraphviz
in your environment source