matplotlib:使用append_axes时,如何指示我想要添加子面板的轴?
我一直在 Matplotlib 库中查看示例 "scatter hist" 。
目前,x/y 子图分别位于顶部和右侧,即:
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)
但是,如果我将子图位置更改为:
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)
即将 x 子面板移动到底部,则append_axes 将 y 子图添加到右侧x 子图,而不是散点图的右侧。 (我会上传图像,但我还没有足够高的声誉来发布图像...... grrr)!
我如何告诉append_axes我想将y子图附加到包含散点图的“主轴”的右侧?我猜测我需要在某处再次指定对象 axScatter (尽管我认为这就是 divider = make_axes_locatable(axScatter)
的用途?!)或者我猜测divider已经设置了一个窗口面板中的网格,我需要告诉append_axes哪个单元格包含主轴。
谢谢,
亚历克斯
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建
axHisty
和axHistx
的顺序似乎很重要。如果你交换最后两个语句的顺序,那么你可以获得所需的效果:这确实像一个错误一样臭。
The order in which you create
axHisty
andaxHistx
appears to matter. If you switch the order of the last two statements then you can get the desired effect:This sure stinks like a bug.