Ask Your Question

Plotting Grid Graph

asked 2014-02-16 06:22:52 -0500

jaia gravatar image

updated 2015-01-17 15:26:13 -0500

FrédéricC gravatar image

I'm trying to plot a grid graph, specifying exactly where vertices should be plotted. (I want the plot to look like an actual grid and later overlay a graphics object on it.) The following code gives a KeyError:

pos_list=[(i,j) for i in range(8) for j in range(12)]
for i in range(len(pos_list)):

How can I get my plot to look like a regular grid?

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted

answered 2014-02-16 08:38:05 -0500

fidbc gravatar image

How about assigning the vertex itself as the position?

G=graphs.GridGraph([8,12])[(v,v) for v in G.vertices()]))
edit flag offensive delete link more

answered 2014-03-31 02:16:32 -0500

alejandroerickson gravatar image

You might want to adjust the spacing or label size with the figsize option:[10,10],pos=dict([(v,v) for v in G.vertices()]))

or store the positions as a property of the graph with

G.set_pos(dict([(v,v) for v in G.vertices()])) 
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-02-16 06:22:52 -0500

Seen: 147 times

Last updated: Mar 31 '14