【发布时间】:2016-06-14 05:33:58
【问题描述】:
我有这样的情节
fig = plt.figure()
desire_salary = (df[(df['inc'] <= int(salary_people))])
print desire_salary
# Create the pivot_table
result = desire_salary.pivot_table('city', 'cult', aggfunc='count')
# plot it in a separate step. this returns the matplotlib axes
ax = result.plot(kind='bar', alpha=0.75, rot=0, label="Presence / Absence of cultural centre")
ax.set_xlabel("Cultural centre")
ax.set_ylabel("Frequency")
ax.set_title('The relationship between the wage level and the presence of the cultural center')
plt.show()
我想将此添加到subplot。我试试
fig, ax = plt.subplots(2, 3)
...
ax = result.add_subplot()
但它会返回 AttributeError:“系列”对象没有属性“add_subplot”。如何检查此错误?
【问题讨论】:
-
您要绘制 6 个图吗?
-
@MaxU,是的,我想将 6 个情节加到一个情节上。我有单独的,但我想把它联合起来
-
检查链接,我在我的回答中提供了 - 我在那里做的几乎一样(我使用的是 seaborn.boxplot 而不是 barplot,你想使用)
-
在提问时尽量提供Minimal, Complete, and Verifiable example。如果有 pandas 问题,请提供示例 input 和 output 数据集(CSV/dict/JSON/Python 代码格式的 5-7 行 作为文本,因此可以在为您编写答案时使用它)。这将有助于避免以下情况:
your code isn't working for me或it doesn't work with my data等。
标签: python pandas matplotlib