用python同时画多个分布图

怎么在同一页面内画多张图?主要用到的是matplotlib库中的subplot函数

附代码:

import seaborn
import numpy
import matplotlib.pyplot as plt
dist_data_1=numpy.random.normal(25,10,500).astype(int)
dist_data_2=numpy.random.normal(30,10,500).astype(int)
fig,axes=plt.subplots(2,2)
#生成2*2的画布
plt.subplot(2,2,1)
#画布中的第一张图
seaborn.distplot(dist_data_1,ax=axes[0][0])
plt.subplot(2,2,2)
seaborn.distplot(dist_data_2,ax=axes[0][1])
plt.subplot(2,2,3)
seaborn.distplot(dist_data_1,ax=axes[1][0])
plt.subplot(2,2,4)
seaborn.distplot(dist_data_2,ax=axes[1][1])
plt.show()

最终得到的结果如图:

 

如果要画1*2的两个图,将axes[][]改成axes[]

  • 3
    点赞
  • 47
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值