簡體   English   中英

在matplotlib中具有2個對數y標度的直方圖?

[英]Histogram with base 2 logarithmic y-scale in matplotlib?

有沒有辦法做到這一點? 當我嘗試指定basebasey時, hist命令似乎無法識別它。

注意:下面的解決方案適用於matplotlib版本<1.3.1。


使用

ax.set_yscale('log', basey=2)

import numpy as np
import matplotlib.pyplot as plt
mu, sigma = 100, 15
fig, ax = plt.subplots()
x = mu + sigma * np.random.randn(10000)
ax.set_yscale('log', basey=2)
n, bins, histpatches = ax.hist(x, 50, facecolor='green', alpha=0.75)
plt.show()

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM