Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with draw_networkx() when saving a figure in pdf format
    primarykey
    data
    text
    <p>When I alter the line width used for edges by specifiying the width argument in the networks draw_networkx() function, e.g:</p> <pre><code>nx.draw_networkx(G, width = 0.03) </code></pre> <p>the image that results from using </p> <pre><code>plt.show() </code></pre> <p>is as expected (in that I can control the edge widths). However, when I use:</p> <pre><code>plt.savefig('foo.pdf') </code></pre> <p>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:</p> <pre><code>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&lt;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() </code></pre> <p>which results in the images at (pdf on the rhs) <a href="http://i49.tinypic.com/2501h6c.jpg" rel="nofollow">http://i49.tinypic.com/2501h6c.jpg</a></p> <p>I've tried oping the pdf in Mac's preview, and in adobe, and the problem persists.</p> <p>Any help/suggestions much appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload