python – matplotlib中基数2对数y标度的直方图?

有没有办法做到这一点?当我尝试指定base或basey时,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()
点赞