When I alter the line width used for edges by specifiying the width argument in the networks draw_networkx() function, e.g:
nx.draw_networkx(G, width = 0.03)
the image that results from using
plt.show()
is as expected (in that I can control the edge widths). However, when I use:
plt.savefig('foo.pdf')
the resulting pdf appears to have an unaffected edge width. Saving as png seems to work fine, but I really need a pdf output. I slightly altered a sample code from the networkx website as an example:
import networkx as nx
import matplotlib.pyplot as plt
G=nx.random_geometric_graph(200,0.125)
pos=nx.get_node_attributes(G,'pos')
dmin=1
ncenter=0
for n in pos:
x,y=pos[n]
d=(x-0.5)**2+(y-0.5)**2
if d<dmin:
ncenter=n
dmin=d
p=nx.single_source_shortest_path_length(G,ncenter)
plt.figure(figsize=(8,8))
nx.draw_networkx_edges(G,pos,nodelist=[ncenter],alpha=1, width = 0.03)
nx.draw_networkx_nodes(G,pos,nodelist=p.keys(),
node_size=80,
node_color=p.values(),
cmap=plt.cm.Reds_r)
plt.xlim(-0.05,1.05)
plt.ylim(-0.05,1.05)
plt.savefig('random_geometric_graph.pdf')
plt.show()
which results in the images at (pdf on the rhs) http://i49.tinypic.com/2501h6c.jpg
I've tried oping the pdf in Mac's preview, and in adobe, and the problem persists.
Any help/suggestions much appreciated!