# 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, 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!).

edit retag close merge delete

I'm keenly interested in this too, and have been for a while (although I haven't gotten around to trying to figure it out).

( 2011-03-21 14:11:38 +0200 )edit

Can 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.

( 2011-03-21 15:08:52 +0200 )edit

Ah.. it's probably because the axes_pad doesn't get passed to the graphics array.

( 2011-03-21 15:16:37 +0200 )edit

@benjaminfjones: I am using 4.5.3. Perhaps it's time for an upgrade. :)

( 2011-03-21 16:57:42 +0200 )edit

Sort by ยป oldest newest most voted

Try 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()])

more

Thanks. I wasn't using the keyword axes_pad explicitly, but rather trying to hack the graph_plot.py module. This works.

( 2011-03-21 16:59:31 +0200 )edit

I wish somebody would fix this at Sage Days 29 right now!

( 2011-03-22 01:42:48 +0200 )edit

Michael 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.

( 2011-03-22 22:37:10 +0200 )edit

See #9211, where a better explanation of the cropping problem and a rough patch are waiting for cleanup and review (from 9 months ago!)

more

For the record, this bug is fixed since sage-4.8

( 2013-06-03 11:14:35 +0200 )edit