首页 > 编程语言 >python matplotlib同时画多个图

python matplotlib同时画多个图

时间:2022-10-17 16:01:19浏览次数:50  
标签:subplot plt figure 多个 python matplotlib add fig1 y1

一.多个图不在一个板里画

from matplotlib import pyplot as plt
x1=['1','2','3']
y1=[4,5,6]
x2=[4,5,7]
y2=[7,8,9]
x3=[12,15,17]
y3=[70,80,90]
fig1=plt.figure()
fig2=plt.figure()
fig3=plt.figure()
ax1=fig1.add_subplot(111)
ax2=fig2.add_subplot(111)
ax3=fig3.add_subplot(111)
ax1.bar(x=x1,height=y1,width=0.5)
ax2.plot(x2,y2)
ax3.plot(x3,y3)
plt.show()

二,多个图,在一个板里画

from matplotlib import pyplot as plt
x1=['1','2','3']
y1=[4,5,6]
x2=[4,5,7]
y2=[7,8,9]
x3=[12,15,17]
y3=[70,80,90]
fig1=plt.figure()

ax1=fig1.add_subplot(311)
ax2=fig1.add_subplot(312)
ax3=fig1.add_subplot(313)
ax1.bar(x=x1,height=y1,width=0.5)
ax2.plot(x2,y2)
ax3.plot(x3,y3)
plt.show()

标签:subplot,plt,figure,多个,python,matplotlib,add,fig1,y1
From: https://www.cnblogs.com/mghhzAnne/p/16799492.html

相关文章