Increasing figure size in Matplotlib

Posted by Anirudh on Stack Overflow See other posts from Stack Overflow or by Anirudh
Published on 2012-12-09T05:01:23Z Indexed on 2012/12/09 5:03 UTC
Read the original article Hit count: 234

I am trying to plot a graph from a distance matrix. The code words fine and gives me a image in 800 * 600 pixels. The image being too small, All the nodes are packed together. I want increase the size of the image. so I added the following line to my code -

figure(num=None, figsize=(10, 10), dpi=80, facecolor='w', edgecolor='k')

After this all I get is a blank 1000 * 1000 image file.

My overall code -

import networkx as nx
import pickle
import matplotlib.pyplot as plt
print "Reading from pickle."
p_file = open('pickles/names')
Names = pickle.load(p_file)
p_file.close()
p_file = open('pickles/distance')
Dist = pickle.load(p_file)
p_file.close()

G = nx.Graph()

print "Inserting Nodes."
for n in Names:
    G.add_node(n)

print "Inserting Edges."
for i in range(601):
  for j in range(601):
    G.add_edge(Names[i],Names[j],weight=Dist[i][j])

print "Drawing Graph."
nx.draw(G)
print "Saving Figure."
#plt.figure(num=None, figsize=(10, 10))
plt.savefig('new.png')
print "Success!"

© Stack Overflow or respective owner

Related posts about python

Related posts about matplotlib