栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在matplotlib中绘制具有固定限制的自动缩放子图

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在matplotlib中绘制具有固定限制的自动缩放子图

Matplotlib /
Pyplot:如何一起放大子图?

http://matplotlib.org/examples/pylab_examples/shared_axis_demo.html

http://matplotlib.org/users/recipes.html

引用最后一个链接:

Fernando Perez提供了一种很好的顶级方法,可以一次在subplots()中创建所有内容(最后请注意“
s”),然后关闭整个对象的x和y共享。您可以单独打开轴的包装:

# new style method 1; unpack the axesfig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex=True,

sharey=True)
ax1.plot(x)

或以支持numpy索引的numrow x numcolumns对象数组的形式返回它们:

# new style method 2; use an axes arrayfig, axs = plt.subplots(2, 2, sharex=True, sharey=True)axs[0,0].plot(x)

如果您使用的是以下版本的旧版本,则

matplotlib
该方法应该有效(也引用了最后一个链接)

轻松创建子图在matplotlib的早期版本中,如果要使用pythonic
API并创建图形实例,然后从中创建子图网格(可能带有共享轴),则需要大量样板代码。例如

# old stylefig = plt.figure()ax1 = fig.add_subplot(221)ax2 = fig.add_subplot(222, sharex=ax1, sharey=ax1)ax3 = fig.add_subplot(223, sharex=ax1, sharey=ax1)ax3 = fig.add_subplot(224, sharex=ax1, sharey=ax1)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/415831.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号