在matplotlib中具有2个对数y标度的直方图?

Cat*_*gia 3 python matplotlib histogram

有没有办法做到这一点?hist当我尝试指定base或时,该命令似乎无法识别它basey.

unu*_*tbu 7

注意:下面的解决方案适用于matplotlib版本<1.3.1.


使用

ax.set_yscale('log', basey=2)
Run Code Online (Sandbox Code Playgroud)
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()
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述