用python同时画多个分布图
生活随笔
收集整理的這篇文章主要介紹了
用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[]
總結
以上是生活随笔為你收集整理的用python同时画多个分布图的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用python将数据标准化
- 下一篇: Matlab中的结构体