小编hum*_*ume的帖子

Pandas plot hist sharex=False 行为不符合预期

我正在尝试从数据框中绘制几个系列的直方图。系列有不同的最大值:

df[[
    'age_sent', 'last_seen', 'forum_reply', 'forum_cnt', 'forum_exp', 'forum_quest'
]].max()
Run Code Online (Sandbox Code Playgroud)

返回:

age_sent       1516.564016
last_seen       986.790035
forum_reply     137.000000
forum_cnt       155.000000
forum_exp        13.000000
forum_quest      10.000000
Run Code Online (Sandbox Code Playgroud)

当我尝试绘制直方图时,我使用sharex=False, subplots=True但看起来sharex属性被忽略:

df[[
    'age_sent', 'last_seen', 'forum_reply', 'forum_cnt', 'forum_exp', 'forum_quest'
]].plot.hist(figsize=(20, 10), logy=True, sharex=False, subplots=True)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明


我可以清楚地分别绘制它们中的每一个,但这不太理想。我也想知道我做错了什么。


我拥有的数据太大也无法包含在内,但很容易创建类似的内容:

ttt = pd.DataFrame({'a': pd.Series(np.random.uniform(1, 1000, 100)), 'b': pd.Series(np.random.uniform(1, 10, 100))})
Run Code Online (Sandbox Code Playgroud)

我现在有:

ttt.plot.hist(logy=True, sharex=False, subplots=True)
Run Code Online (Sandbox Code Playgroud)

检查 x 轴。我希望它是这种方式(但使用一个带有子图的命令)。

ttt['a'].plot.hist(logy=True)
ttt['b'].plot.hist(logy=True)
Run Code Online (Sandbox Code Playgroud)

python matplotlib pandas

7
推荐指数
1
解决办法
1882
查看次数

标签 统计

matplotlib ×1

pandas ×1

python ×1