您好,欢迎来到微智科技网。
搜索
您的当前位置:首页matplotlib制图——子图-subplot及多图figure

matplotlib制图——子图-subplot及多图figure

来源:微智科技网
matplotlib制图——⼦图-subplot及多图figure

import matplotlib.pyplot as pltimport numpy as npimport pandas as pdx=np.arange(1,100)fig=plt.figure()

ax1=fig.add_subplot(221) #2*2的图形 在第⼀个位置ax1.plot(x,x)

ax2=fig.add_subplot(222)ax2.plot(x,-x)

ax3=fig.add_subplot(223)ax3.plot(x,x**2)

ax3=fig.add_subplot(224)ax3.plot(x,np.log(x))plt.show()

同时绘制两张图

import matplotlib.pyplot as pltimport numpy as npimport pandas as pdfig1=plt.figure()

ax1=fig1.add_subplot(111)ax1.plot([1,2,3],[3,2,1])fig2=plt.figure()

ax2=fig2.add_subplot(111)ax2.plot([1,2,3],[1,2,3])plt.show()

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 7swz.com 版权所有 赣ICP备2024042798号-8

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务