[英]How to change pandas dataframe plot from vertical to horizontal and add line spacing for the axis labels?
I plotted a dataframe using the following command我使用以下命令绘制了 dataframe
df['col1'].value_counts().plot.bar(orientation='vertical')
The output is shown as above. output 如上图所示。 I would like to change two things:我想改变两点:
I have tried a few things but none of them have any visible effects.我已经尝试了一些东西,但它们都没有任何明显的效果。 eg,例如,
plt.xticks(linespacing=1.5)
np.linspace(-1, 1, 10000)
You can plot horizontally directly.您可以直接水平 plot。 Also, consider setting a different font size in advance, eg:另外,请考虑提前设置不同的字体大小,例如:
plt.rcParams.update({'font.size': 6}) # Arbitrary
df['col1'].value_counts().plot(kind="barh", figsize=(5, 20))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.