AI智能
改变未来

第3节课Matplotlib作业

height = [160,163,175,180,176,177,168,189,188,177,174,170,173,181]
max(height)
min(height)
cha=max(height)-min(height)

b=5
bi=round(cha/b)

b2=cha/b

print(cha)

print(bi)

print(b2)

plt.hist(height,bins=bi,density=True)

plt.hist(height,bins=bi)

#display label
plt.xlabel(“区间”)
plt.ylabel(“频数/频率”)
plt.title(‘height直方图’)
plt.show()

fig=plt.figure()
plt.figure(figsize=(14,8))
gs = fig.add_gridspec(3,3)

fig.add_subplot(gs[0,:2])

fig.add_subplot(gs[1:3,:2])

fig.add_subplot(gs[1:3,2:3])

ax1= fig.add_subplot(gs[0,:2])
ax2= fig.add_subplot(gs[1:3,:2])
ax3=fig.add_subplot(gs[1:3,2:3])
fig.tight_layout()
#fig.add_subplot(gs[1:2,:2])

fig.add_subplot(gs[1,1])

ax1.plot([1,4],[1,4])
ax3.plot([1,4],[1,4])
#ax2.plot([1,30],[1,30])
ax2.scatter([random.randint(10,30) for i in range(30)],[random.randint(10,30) for i in range(30)])

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » 第3节课Matplotlib作业