Ask Your Question
2

Why does graph plotting crop so aggressively, and what is a work-around?

asked 2011-03-21 14:00:06 +0200

Sammy Black gravatar image

updated 2023-01-10 00:01:07 +0200

tmonteil gravatar image

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

(http://trac.sagemath.org/sage_trac/ti...)

edit retag flag offensive close merge delete

Comments

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

niles gravatar imageniles ( 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.

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

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

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

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

Sammy Black gravatar imageSammy Black ( 2011-03-21 16:57:42 +0200 )edit

2 Answers

Sort by ยป oldest newest most voted
3

answered 2011-03-21 15:18:39 +0200

benjaminfjones gravatar image

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()])
sage: G.show(axes_pad=0.1)
edit flag offensive delete link more

Comments

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

Sammy Black gravatar imageSammy Black ( 2011-03-21 16:59:31 +0200 )edit

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

William Stein gravatar imageWilliam Stein ( 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.

Jason Grout gravatar imageJason Grout ( 2011-03-22 22:37:10 +0200 )edit
2

answered 2011-03-21 16:54:21 +0200

Jason Grout gravatar image

updated 2011-03-21 16:55:19 +0200

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

edit flag offensive delete link more

Comments

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-03-21 14:00:06 +0200

Seen: 1,064 times

Last updated: Mar 21 '11