In networkx i draw 4 points, connect them with lines so i get square. But i can not find solution to fill this wireframe rectangle with some color. Do we have any tools or hint for filling areas in networkx?
Asked
Active
Viewed 134 times
0
-
Matplotlib can do all your need. – swatchai May 27 '19 at 06:55
-
@swatchai yes, but with mathplotlib i have to draw all myself with no abstraction about nodes and edges in networkx. a lot of wheel reinventing stuff... i want to draw actually graph structure and select some regions of graph with color filling – Apollorider May 27 '19 at 07:55
-
@Apollorider The "region of the graph" as defined by the interior of some edge cycle is dependent on the way the graph is drawn. You cannot define it from graph theory abstractions. – Leporello May 27 '19 at 09:58
-
You can use the output of the layout algorithms of networkx, which gives you the positions of the nodes. – Sparky05 May 27 '19 at 12:43
-
@Leporello, yes, you're right. – Apollorider May 27 '19 at 12:58
-
@Sparky05, can you explain some details, how could i do that? thank you! – Apollorider May 27 '19 at 12:59
-
@Apollorider For instance you could use [networkx.draw_networkx_edges()](https://networkx.github.io/documentation/networkx-1.10/reference/generated/networkx.drawing.nx_pylab.draw_networkx_edges.html#networkx.drawing.nx_pylab.draw_networkx_edges) which returns a [matplotlib.collections.LineCollection](https://matplotlib.org/api/collections_api.html#matplotlib.collections.LineCollection) object, whose `facecolors` you can then set. You need to have or acquire some familiarity with matplotlib, though... – Leporello May 27 '19 at 13:39
-
@Leporello, wow, really. thank you a lot. – Apollorider May 27 '19 at 14:16