Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib: when using append_axes, how can I indicate the axes I want to add the subpanel to?

I've been looking at the example "scatter hist" in the Matplotlib gallery.

At the moment the x/y subplots are at the top and on the right respectively, i.e.:

divider = make_axes_locatable(axScatter)
axHistx = divider.append_axes("top", 1.2, pad=0.1, sharex=axScatter)
axHisty = divider.append_axes("right", 1.2, pad=0.1, sharey=axScatter)

However, if I change the subplot locations to:

divider = make_axes_locatable(axScatter)
axHistx = divider.append_axes("bottom", 1.2, pad=0.1, sharex=axScatter)
axHisty = divider.append_axes("right", 1.2, pad=0.1, sharey=axScatter)

i.e. move the x subpanel to the bottom, then append_axes adds the y subplot to the right of the x subplot, rather than the right of the scatter plot. (I'd upload the image but I don't have a high enough reputation yet to post images... grrr)!

How can I tell append_axes that I want to append the y subplot to the right of the "main axes" containing the scatter plot? I'm guessing that I need to either specify the object axScatter again somewhere (though I thought that's what divider = make_axes_locatable(axScatter) was for?!) or I'm guessing that divider has set up a grid in the window panel and I need to tell append_axes which cell contains the main axes.

Thanks,

Alex

like image 971
aim Avatar asked Nov 05 '11 13:11

aim


1 Answers

The order in which you create axHisty and axHistx appears to matter. If you switch the order of the last two statements then you can get the desired effect:

divider = make_axes_locatable(axScatter)
axHisty = divider.append_axes("right", 1.2, pad=0.1,  sharey=axScatter)
axHistx = divider.append_axes("bottom", 1.2, pad=0.1, sharex=axScatter)

This sure stinks like a bug.

like image 155
crayzeewulf Avatar answered Oct 07 '22 11:10

crayzeewulf