ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 03 Jun 2013 11:14:35 +0200Why does graph plotting crop so aggressively, and what is a work-around?https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/Surely, the Sage community is aware of this bug. For example, there is [this ticket](http://trac.sagemath.org/sage_trac/ticket/7299), in which the problem is supposed to be fixed. But it's not!
A patch is described: in `sage/graphs/graph_plot.py` we can add the line(?)
> `G._extra_kwds['axes_pad']=.05 `
Am I to change this value in order to fix this over-zealous cropping behavior? No matter what I do, in this regard, I still end up with graph vertices partially cut off.
What's the easy work-around? I would like to be able to plot `graphics_array` objects with several graphs (with their vertices clearly shown!).
(http://trac.sagemath.org/sage_trac/ticket/7299)Mon, 21 Mar 2011 14:00:06 +0100https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/Comment by benjaminfjones for <p>Surely, the Sage community is aware of this bug. For example, there is <a href="http://trac.sagemath.org/sage_trac/ticket/7299">this ticket</a>, in which the problem is supposed to be fixed. But it's not!</p>
<p>A patch is described: in <code>sage/graphs/graph_plot.py</code> we can add the line(?)</p>
<blockquote>
<p><code>G._extra_kwds['axes_pad']=.05</code></p>
</blockquote>
<p>Am I to change this value in order to fix this over-zealous cropping behavior? No matter what I do, in this regard, I still end up with graph vertices partially cut off.</p>
<p>What's the easy work-around? I would like to be able to plot <code>graphics_array</code> objects with several graphs (with their vertices clearly shown!).</p>
<p>(<a href="http://trac.sagemath.org/sage_trac/ticket/7299">http://trac.sagemath.org/sage_trac/ti...</a>)</p>
https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21959#post-id-21959Ah.. it's probably because the `axes_pad` doesn't get passed to the graphics array. Mon, 21 Mar 2011 15:16:37 +0100https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21959#post-id-21959Comment by Sammy Black for <p>Surely, the Sage community is aware of this bug. For example, there is <a href="http://trac.sagemath.org/sage_trac/ticket/7299">this ticket</a>, in which the problem is supposed to be fixed. But it's not!</p>
<p>A patch is described: in <code>sage/graphs/graph_plot.py</code> we can add the line(?)</p>
<blockquote>
<p><code>G._extra_kwds['axes_pad']=.05</code></p>
</blockquote>
<p>Am I to change this value in order to fix this over-zealous cropping behavior? No matter what I do, in this regard, I still end up with graph vertices partially cut off.</p>
<p>What's the easy work-around? I would like to be able to plot <code>graphics_array</code> objects with several graphs (with their vertices clearly shown!).</p>
<p>(<a href="http://trac.sagemath.org/sage_trac/ticket/7299">http://trac.sagemath.org/sage_trac/ti...</a>)</p>
https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21958#post-id-21958@benjaminfjones: I am using 4.5.3. Perhaps it's time for an upgrade. :)Mon, 21 Mar 2011 16:57:42 +0100https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21958#post-id-21958Comment by niles for <p>Surely, the Sage community is aware of this bug. For example, there is <a href="http://trac.sagemath.org/sage_trac/ticket/7299">this ticket</a>, in which the problem is supposed to be fixed. But it's not!</p>
<p>A patch is described: in <code>sage/graphs/graph_plot.py</code> we can add the line(?)</p>
<blockquote>
<p><code>G._extra_kwds['axes_pad']=.05</code></p>
</blockquote>
<p>Am I to change this value in order to fix this over-zealous cropping behavior? No matter what I do, in this regard, I still end up with graph vertices partially cut off.</p>
<p>What's the easy work-around? I would like to be able to plot <code>graphics_array</code> objects with several graphs (with their vertices clearly shown!).</p>
<p>(<a href="http://trac.sagemath.org/sage_trac/ticket/7299">http://trac.sagemath.org/sage_trac/ti...</a>)</p>
https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21961#post-id-21961I'm keenly interested in this too, and have been for a while (although I haven't gotten around to trying to figure it out).Mon, 21 Mar 2011 14:11:38 +0100https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21961#post-id-21961Comment by benjaminfjones for <p>Surely, the Sage community is aware of this bug. For example, there is <a href="http://trac.sagemath.org/sage_trac/ticket/7299">this ticket</a>, in which the problem is supposed to be fixed. But it's not!</p>
<p>A patch is described: in <code>sage/graphs/graph_plot.py</code> we can add the line(?)</p>
<blockquote>
<p><code>G._extra_kwds['axes_pad']=.05</code></p>
</blockquote>
<p>Am I to change this value in order to fix this over-zealous cropping behavior? No matter what I do, in this regard, I still end up with graph vertices partially cut off.</p>
<p>What's the easy work-around? I would like to be able to plot <code>graphics_array</code> objects with several graphs (with their vertices clearly shown!).</p>
<p>(<a href="http://trac.sagemath.org/sage_trac/ticket/7299">http://trac.sagemath.org/sage_trac/ti...</a>)</p>
https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21960#post-id-21960Can you post code that replicates the problem and the Sage version you are using. In 4.6.2 I do: sage: g = Graph({0:{1:'a'}, 1:{2:'b'}, 2:{0:'c'}}); g.plot() --- and I get a nice triangle, no cropping occurs. I tried a bunch of other graphs from the database and they all seem fine too.
Mon, 21 Mar 2011 15:08:52 +0100https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21960#post-id-21960Answer by Jason Grout for <p>Surely, the Sage community is aware of this bug. For example, there is <a href="http://trac.sagemath.org/sage_trac/ticket/7299">this ticket</a>, in which the problem is supposed to be fixed. But it's not!</p>
<p>A patch is described: in <code>sage/graphs/graph_plot.py</code> we can add the line(?)</p>
<blockquote>
<p><code>G._extra_kwds['axes_pad']=.05</code></p>
</blockquote>
<p>Am I to change this value in order to fix this over-zealous cropping behavior? No matter what I do, in this regard, I still end up with graph vertices partially cut off.</p>
<p>What's the easy work-around? I would like to be able to plot <code>graphics_array</code> objects with several graphs (with their vertices clearly shown!).</p>
<p>(<a href="http://trac.sagemath.org/sage_trac/ticket/7299">http://trac.sagemath.org/sage_trac/ti...</a>)</p>
https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?answer=12212#post-id-12212See [#9211](http://trac.sagemath.org/sage_trac/ticket/9211), where a better explanation of the cropping problem and a rough patch are waiting for cleanup and review (from 9 months ago!)Mon, 21 Mar 2011 16:54:21 +0100https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?answer=12212#post-id-12212Comment by tmonteil for <p>See <a href="http://trac.sagemath.org/sage_trac/ticket/9211">#9211</a>, where a better explanation of the cropping problem and a rough patch are waiting for cleanup and review (from 9 months ago!)</p>
https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=17584#post-id-17584For the record, this bug is fixed since sage-4.8Mon, 03 Jun 2013 11:14:35 +0200https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=17584#post-id-17584Answer by benjaminfjones for <p>Surely, the Sage community is aware of this bug. For example, there is <a href="http://trac.sagemath.org/sage_trac/ticket/7299">this ticket</a>, in which the problem is supposed to be fixed. But it's not!</p>
<p>A patch is described: in <code>sage/graphs/graph_plot.py</code> we can add the line(?)</p>
<blockquote>
<p><code>G._extra_kwds['axes_pad']=.05</code></p>
</blockquote>
<p>Am I to change this value in order to fix this over-zealous cropping behavior? No matter what I do, in this regard, I still end up with graph vertices partially cut off.</p>
<p>What's the easy work-around? I would like to be able to plot <code>graphics_array</code> objects with several graphs (with their vertices clearly shown!).</p>
<p>(<a href="http://trac.sagemath.org/sage_trac/ticket/7299">http://trac.sagemath.org/sage_trac/ti...</a>)</p>
https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?answer=12210#post-id-12210Try this:
sage: g1 = Graph({0:{1:'a'}, 1:{2:'b'}, 2:{0:'c'}})
sage: g2 = Graph({0:{1:'a'}, 1:{2:'b'}, 2:{3:'c'}, 3:{0:'d'}})
sage: G = graphics_array([g1.plot(), g2.plot()])
sage: G.show(axes_pad=0.1)
Mon, 21 Mar 2011 15:18:39 +0100https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?answer=12210#post-id-12210Comment by Sammy Black for <p>Try this:</p>
<pre><code>sage: g1 = Graph({0:{1:'a'}, 1:{2:'b'}, 2:{0:'c'}})
sage: g2 = Graph({0:{1:'a'}, 1:{2:'b'}, 2:{3:'c'}, 3:{0:'d'}})
sage: G = graphics_array([g1.plot(), g2.plot()])
sage: G.show(axes_pad=0.1)
</code></pre>
https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21957#post-id-21957Thanks. I wasn't using the keyword `axes_pad` explicitly, but rather trying to hack the `graph_plot.py` module. This works.Mon, 21 Mar 2011 16:59:31 +0100https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21957#post-id-21957Comment by Jason Grout for <p>Try this:</p>
<pre><code>sage: g1 = Graph({0:{1:'a'}, 1:{2:'b'}, 2:{0:'c'}})
sage: g2 = Graph({0:{1:'a'}, 1:{2:'b'}, 2:{3:'c'}, 3:{0:'d'}})
sage: G = graphics_array([g1.plot(), g2.plot()])
sage: G.show(axes_pad=0.1)
</code></pre>
https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21948#post-id-21948Michael D. would be a natural person to take a look at this, if he wants to dive into the Sage plotting code. He might glance at #9211 and see what he thinks about it.Tue, 22 Mar 2011 22:37:10 +0100https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21948#post-id-21948Comment by William Stein for <p>Try this:</p>
<pre><code>sage: g1 = Graph({0:{1:'a'}, 1:{2:'b'}, 2:{0:'c'}})
sage: g2 = Graph({0:{1:'a'}, 1:{2:'b'}, 2:{3:'c'}, 3:{0:'d'}})
sage: G = graphics_array([g1.plot(), g2.plot()])
sage: G.show(axes_pad=0.1)
</code></pre>
https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21953#post-id-21953I wish somebody would fix this at Sage Days 29 right now!Tue, 22 Mar 2011 01:42:48 +0100https://ask.sagemath.org/question/8016/why-does-graph-plotting-crop-so-aggressively-and-what-is-a-work-around/?comment=21953#post-id-21953