from matplotlib import pyplot as plt
fig, axes = plt.subplots(5, 4) # axes is a numpy array of pyplot Axes
axes = iter(axes.ravel()) # set up an iterator for the set of axes.
categoricals = df.columns[df.dtypes == 'category']
numeric = df.columns[df.dtypes != 'category']
for col in categoricals:
ax = df[col].value_counts().plot(kind='bar', ax=axes.next())
# do other stuff with ax, formatting etc.
# the plot method returns the axis used for the plot for further manipulation
for col in numeric:
ax = df[col].plot(ax=axes.next())
# etc.
你真的应该发布你尝试过的代码和一些示例数据。否则不可能知道最好的方法。但是,我认为您可能需要尝试以下方法,即使用
matplotlib
API而不是pandas
,这样可以更好地控制每个绘图中的内容:这只是给你一些想法,因为我不知道你的数据的细节,你想如何绘制每一列,你有什么样的数据类型等等
相关问题 更多 >
编程相关推荐