日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

Matplotlib实例教程(六)直方图

發(fā)布時(shí)間:2025/4/5 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Matplotlib实例教程(六)直方图 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

前言

  • 🔗 運(yùn)行環(huán)境:python3
  • 🚩 作者:K同學(xué)啊
  • 🥇 精選專(zhuān)欄:《深度學(xué)習(xí)100例》
  • 🔥 推薦專(zhuān)欄:《小白入門(mén)深度學(xué)習(xí)》
  • 📚 選自專(zhuān)欄:《Matplotlib教程》
  • 🧿 優(yōu)秀專(zhuān)欄:《Python入門(mén)100題》

代碼實(shí)現(xiàn)

import numpy as np import matplotlib.pyplot as pltn_bins = 10 x = np.random.randn(1000, 3)fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(11,8)) #subplots創(chuàng)建多個(gè)子圖 ax0=axes[0,0] ax1=axes[0,1] ax2=axes[1,0] ax3=axes[1,1]colors = ['red', 'tan', 'lime'] ax0.hist(x, n_bins, density=True, histtype='bar', color=colors, label=colors) ax0.legend(prop={'size': 8}) ax0.set_title('bars with legend')ax1.hist(x, n_bins, density=True, histtype='bar', stacked=True) ax1.set_title('stacked bar')ax2.hist(x, n_bins, histtype='step', stacked=True) ax2.set_title('stack step (unfilled)')x_multi = [np.random.randn(n) for n in [10000, 5000, 2000]] ax3.hist(x_multi, n_bins, histtype='bar') ax3.set_title('different sample sizes')fig.tight_layout() #自動(dòng)調(diào)整子圖參數(shù) plt.show()

總結(jié)

以上是生活随笔為你收集整理的Matplotlib实例教程(六)直方图的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。