<div dir="ltr"><div>Hi Eric, </div><div><br></div><div>This is brilliant, the problem is solved on the linux, and I&#39;m totally happy with that (as can get on with my work :) ), but please be advised that this seems to have created some issue the matplotlib mac OSX backend doesn&#39;t like: </div><div><br></div><div>on mac OSX pylab.show() yields:   </div><div><br></div><div>---------------------------------------------------------------------------<br></div><div><div>TypeError                                 Traceback (most recent call last)</div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)</div><div>     57     def draw_wrapper(artist, renderer, *args, **kwargs):</div><div>     58         before(artist, renderer)</div><div>---&gt; 59         draw(artist, renderer, *args, **kwargs)</div><div>     60         after(artist, renderer)</div><div>     61</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/figure.pyc in draw(self, renderer)</div><div>   1077         dsu.sort(key=itemgetter(0))</div><div>   1078         for zorder, a, func, args in dsu:</div><div>-&gt; 1079             func(*args)</div><div>   1080</div><div>   1081         renderer.close_group(&#39;figure&#39;)</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)</div><div>     57     def draw_wrapper(artist, renderer, *args, **kwargs):</div><div>     58         before(artist, renderer)</div><div>---&gt; 59         draw(artist, renderer, *args, **kwargs)</div><div>     60         after(artist, renderer)</div><div>     61</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in draw(self, renderer, inframe)</div><div>   2090</div><div>   2091         for zorder, a in dsu:</div><div>-&gt; 2092             a.draw(renderer)</div><div>   2093</div><div>   2094         renderer.close_group(&#39;axes&#39;)</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)</div><div>     57     def draw_wrapper(artist, renderer, *args, **kwargs):</div><div>     58         before(artist, renderer)</div><div>---&gt; 59         draw(artist, renderer, *args, **kwargs)</div><div>     60         after(artist, renderer)</div><div>     61</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/text.pyc in draw(self, renderer)</div><div>    536         renderer.open_group(&#39;text&#39;, self.get_gid())</div><div>    537</div><div>--&gt; 538         bbox, info, descent = self._get_layout(renderer)</div><div>    539         trans = self.get_transform()</div><div>    540</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/text.pyc in _get_layout(self, renderer)</div><div>    309         tmp, lp_h, lp_bl = renderer.get_text_width_height_descent(&#39;lp&#39;,</div><div>    310                                                          self._fontproperties,</div><div>--&gt; 311                                                          ismath=False)</div><div>    312         offsety = (lp_h - lp_bl) * self._linespacing</div><div>    313</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.pyc in get_text_width_height_descent(self, s, prop, ismath)</div><div>    164         size = self.points_to_pixels(points)</div><div>    165         width, height, descent = self.gc.get_text_width_height_descent(</div><div>--&gt; 166             six.text_type(s), family, size, weight, style)</div><div>    167         return  width, height, 0.0*descent</div><div>    168</div></div><div><br></div><div>Best wishes,</div><div>Jan Zaucha<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 26 January 2015 at 21:06, Eric Talevich <span dir="ltr">&lt;<a href="mailto:eric.talevich@gmail.com" target="_blank">eric.talevich@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Thanks, Jan, that was helpful for debugging. I pushed a fix to GitHub, so if you can install the development version of Biopython, it should work for you now.<br><br>The problem was a bug in networkx release 1.9.1 (and maybe others) that existed between August 2013 and September 2014. The networkx &quot;draw&quot; function would pass all keywords to &quot;draw_networkx&quot;, except that while &quot;draw_networkx&quot; has a keywords argument &quot;with_labels&quot; that defaults to True, &quot;draw&quot; would override this to &quot;False&quot; unless it had been specified explicitly. It has since been fixed in networkx and should be included in the next release:<br><a href="https://github.com/networkx/networkx/blame/master/networkx/drawing/nx_pylab.py" target="_blank">https://github.com/networkx/networkx/blame/master/networkx/drawing/nx_pylab.py</a><br><br></div><div><div class="h5"><div class="gmail_quote"><br>On Mon, Jan 26, 2015 at 2:41 AM, Jan Zaucha <span dir="ltr">&lt;<a href="mailto:Jan.Zaucha@bristol.ac.uk" target="_blank">Jan.Zaucha@bristol.ac.uk</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks Eric,<div><br></div><div>I&#39;m using biopython 1.65 and networkx 1.9.1. </div><div><br></div><div>When I ran the commands you&#39;ve proposed I still see the node names assigned:</div><div>[Clade(branch_length=2.0, name=&#39;foo&#39;), Clade(branch_length=4.0, name=&#39;bar), Clade(...), ... ]<br></div><div><br></div><div>I&#39;m not sure what the source file format is, I created the tree myself from a distance matrix, the examples I was looking at were importing trees </div><div>from <span style="font-size:12.8px">PhyloXML. Here&#39;s the code I&#39;m running, maybe this will help: </span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">###################### testing graphviz</span></div><div><div><span style="font-size:12.8px">from Bio import Phylo</span></div><div><span style="font-size:12.8px">from Bio.Phylo.TreeConstruction import _DistanceMatrix</span></div><div><span style="font-size:12.8px">from Bio.Phylo.TreeConstruction import DistanceTreeConstructor</span></div><div><span style="font-size:12.8px">import pylab</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">names = [&#39;foo&#39;, &#39;bar&#39;, &#39;cat&#39;, &#39;dog&#39;]</span></div><div><span style="font-size:12.8px">matrix = [[0], [1, 0], [2, 3, 0], [4, 5, 6, 0]]</span></div><div><span style="font-size:12.8px">m = _DistanceMatrix(names, matrix)</span></div><div><span style="font-size:12.8px">constructor = DistanceTreeConstructor()</span></div><div><span style="font-size:12.8px">tree = constructor.nj(m)</span></div><div><span style="font-size:12.8px">graph = Phylo.to_networkx(tree)</span></div><div><span style="font-size:12.8px">print graph.nodes()</span></div><div><span style="font-size:12.8px">Phylo.draw_graphviz(tree, prog=&quot;neato&quot;, node_size=50)</span></div><div><span style="font-size:12.8px">pylab.show()</span></div><div style="font-size:12.8px">##########################</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I still don&#39;t understand where I&#39;m going wrong.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Best wishes, </div><span><font color="#888888"><div style="font-size:12.8px">Jan</div><div style="font-size:12.8px"><br></div></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 23 January 2015 at 16:33, Eric Talevich <span dir="ltr">&lt;<a href="mailto:eric.talevich@gmail.com" target="_blank">eric.talevich@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div>Hi Jan,<br><br></div>Could you show us some more information about your tree, like the first few lines you see with &quot;print tree&quot;? Also try converting the tree to a NetworkX graph, which is the intermediate form used by draw_graphviz, and inspecting the nodes to see if names were lost or retained:<br><br></div><div>graph = Phylo.to_networkx(tree)<br></div><div>graph.nodes()<br><br></div><div>Also:<br><br></div><div>- What was the source file format (e.g. Newick, Nexus, PhyloXML, NeXML)<br></div><div>- Which versions of Biopython and NetworkX are you using?<br></div><div><br></div>It&#39;s possible the node names are assigned to a different attribute than the node name, in which case you can use the &quot;label_func&quot; argument in draw_graphviz to retrieve the name from the graph node.<br><br></div>Hope that helps,<br>Eric<br><div><div><br><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Thu, Jan 22, 2015 at 8:02 AM, Jan Zaucha <span dir="ltr">&lt;<a href="mailto:Jan.Zaucha@bristol.ac.uk" target="_blank">Jan.Zaucha@bristol.ac.uk</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div dir="ltr"><span style="font-size:13px">Hi everyone,</span><div style="font-size:13px"><br></div><div style="font-size:13px">I&#39;m trying to visualize the trees I generate, but for some reason the plots do not display the node names. When I print the tree each node has an associated name (string format). Phylo.draw(tree) also works fine and plots a tree with the node names. </div><div style="font-size:13px"><br></div><div style="font-size:13px">I simply use:</div><div style="font-size:13px">Phylo.draw_graphviz(tree)<br></div><div style="font-size:13px">pylab.show()</div><div style="font-size:13px"><br></div><div style="font-size:13px">There is no error, I can&#39;t work out how to force the node names to be printed. </div><div style="font-size:13px"><br></div><div style="font-size:13px">Any ideas?</div><div style="font-size:13px"><br></div><div style="font-size:13px">Thanks,</div><div style="font-size:13px">Jan Zaucha</div><span><font color="#888888"><div><br></div>-- <br><div><div dir="ltr"><div>Jan Zaucha</div><div>Bristol Centre for Complexity Sciences<br></div><div>Computational Genomics Group<br></div><div>University of Bristol</div></div></div>
</font></span></div>
<br></div></div>_______________________________________________<br>
Biopython mailing list  -  <a href="mailto:Biopython@mailman.open-bio.org" target="_blank">Biopython@mailman.open-bio.org</a><br>
<a href="http://mailman.open-bio.org/mailman/listinfo/biopython" target="_blank">http://mailman.open-bio.org/mailman/listinfo/biopython</a><br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div>Jan Zaucha</div><div>Bristol Centre for Complexity Sciences<br></div><div>Computational Genomics Group<br></div><div>University of Bristol</div></div></div>
</div>
</div></div></blockquote></div><br></div></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Jan Zaucha</div><div>Bristol Centre for Complexity Sciences<br></div><div>Computational Genomics Group<br></div><div>University of Bristol</div></div></div>
</div>