Ask Your Question
0

Making a graphics array with different numbers of plots in each row

asked 2013-10-06 20:04:30 +0100

jaia gravatar image

I'm trying to create a graphics array with one plot in the first row and three in the second. Here's a minimal example:

p0 = plot(x)
p1 = plot(x^2)
p2 = plot(x^3)
g = graphics_array([[p0], [p1, p2]])
g.show()

When executing this, I get each plot separately and then an error message reading, "TypeError: array (=[[], [, ]]) must be a list of lists of Graphics objects". What am I doing wrong? How is what I have not a list of lists of Graphics objects?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2013-10-07 00:53:55 +0100

tmonteil gravatar image

The documentation of the graphics_array() fonction is not very explicit, but the documentation of the GraphicsArray class states: "GraphicsArray takes a (m x n) list of lists of graphics objects and plots them all on one canvas." Hence, each row must have the same number of Graphics objects.

In your case, a possible workaround could be to add empty graphics in the array:

sage: empty = Graphics()    
sage: empty.axes(False)
sage: graphics_array([[p0,empty],[p1, p2]])
edit flag offensive delete link more

Comments

Thanks; I recently discovered that workaround myself. In that case, can I make the blank graphics objects smaller and give the real plot more room?

jaia gravatar imagejaia ( 2013-10-07 00:58:41 +0100 )edit

i don't think that there is a Sage function to do this out of the box, but you can have a look at matplotlib directly, see the source of `GraphicsArray._render` http://hg.sagemath.org/sage-main/src/0f8fd922eaed351e39f913f1317d319dcceb4c01/sage/plot/graphics.py?at=default#cl-2963 or http://matplotlib.org/users/gridspec.html

tmonteil gravatar imagetmonteil ( 2013-10-07 01:16:56 +0100 )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

1 follower

Stats

Asked: 2013-10-06 20:04:30 +0100

Seen: 1,035 times

Last updated: Oct 07 '13