关于处理子图的布局 [英] On handling the layout of subfigures

查看:48
本文介绍了关于处理子图的布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚阅读了 subplot2grid 的介绍 http://matplotlib.org/用户/gridspec.html

I just read an introduction to subplot2grid http://matplotlib.org/users/gridspec.html

我不明白为什么它像这样使用

I don't understand why it is used like

fig = plt.figure()
plt.subplot2grid((2,2),(0, 0))

而不是

fig = plt.figure()
fig.subplot2grid((2,2),(0, 0))

通过 plt.subplot2grid(...),如果我创建了多个图形,则该子图形位于哪个图形上?

By plt.subplot2grid(...), if I have created multiple figures, which figure the subplot is on?

推荐答案

plt.* 函数作用于当前图形.要获取当前数字,您可以

plt.* functions act on the current figure. To get the current figure you can do

fig = plt.gcf()

因此,在第二种情况下,您可以执行以下操作:

So, in your second case you can do:

# Add subplots to the current figure
plt.subplot2grid((2, 2), (0, 0))

# Get the current figure. This will hold the subplots created in the previous command
fig = plt.gcf()

希望这会有所帮助.

这篇关于关于处理子图的布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆