in NetworkX show graph with nodes at exact (x,y) position. Result is rotated
graph, networkx, python, rotation
Solution
Your NetworkX plot is a vertical reflection of the plot you are trying to mimic. To fix this, for each y coordinate, use `height - y` where `height` is the height of your figure.
Problem
I am getting a trouble in showing my graph on networkX. I extract some corner-points from a picture given in input and save the corner-points as node of a graph in NetworkX. The node contains the (x,y) positions of the corner-points as they are retrieved. I show then the graph placing the nodes at their exact (x,y) position. However, when I show the graph using `nx.draw()` the graph shows the shape retrieved in the picture all the way around. Here is some code for you to understand: ``` pe = nx.Graph() pe.add_node('p1', posxy=(ap[0][0], ap[0][1])) pe.add_node('p2', posxy=(ap[1][0], ap[1][2])) pe.add_node('p3', posxy=(ap[2][0], ap[2][3])) pe.add_node('p4', posxy=(ap[3][0], ap[3][4])) pe.add_node('p5', posxy=(ap[4][0], ap[4][5])) pe.add_cycle(['p1','p2','p3','p4','p5']) positions = nx.get_node_attributes(pe,'posxy') nx.draw(pe, positions, node_size=500) ``` where `posxy=(ap[0][0], ap[0][1])` is the position in the plane of the found corner-point. The corner-points are saved in a list `ap`. Here is the picture of the shape retrieved: and this the shown graph: Why is the output shown all the way aroud? How can I rotate the graph in a way that resembles the initial shape detected?