Ask Your Question

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

asked 2013-10-06 13:04:30 -0500

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

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

answered 2013-10-06 17:53:55 -0500

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


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-06 17:58:41 -0500 )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` or

tmonteil gravatar imagetmonteil ( 2013-10-06 18:16:56 -0500 )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


Asked: 2013-10-06 13:04:30 -0500

Seen: 564 times

Last updated: Oct 06 '13