【发布时间】:2014-07-11 03:15:24
【问题描述】:
我正在尝试迭代由 pandas.DataFrame.hist 重新调整的 matplotlib.axes.AxesSubplot 数组,以使每个子直方图逻辑。以下示例代码不起作用
from pandas import DataFrame
import numpy as np
import matplotlib.pyplot as plt
x = np.random.uniform(0, 100, size=1000)
y = x *x + 50*x*np.random.randn(1000)
z = x * y + 50*y*np.random.randn(1000)
frame = DataFrame({'z' : z,'x' : x , 'y' : y})
Histograms = frame.hist(bins=50)
for axis in np.nditer(Histograms,"refs_ok"):
axis.set_yscale("log", nonposy='clip')
plt.show()
【问题讨论】:
-
"以下示例代码不起作用" -> 这是什么意思?你有任何错误吗?还是出乎意料的输出(您期望的输出是什么)?
-
“不工作”总是意味着“没有按我的预期执行”,但我们不知道您的期望。因此,请说明您的预期并描述您的观察结果。
-
对不起,我得到的异常是“ValueError: Iterator global flags must be a list or tuple of strings”。
标签: python arrays loops matplotlib pandas