[英]Not shown x-axis labels in matplotlib subplots from pandas dataframe
I try to print out subplots.我尝试打印出子图。 Sadly just the last of those plots has x axis labels / dates shown.
可悲的是,这些图中只有最后一个显示了 x 轴标签/日期。 How can I show the date below each graph.
如何在每个图表下方显示日期。
It looks like this, but I wan't x axis for all graphs看起来像这样,但我不想为所有图表设置 x 轴
import matplotlib.pyplot as plt
axes = dfDiscoverNerPivot.plot.line(x="date",subplots=True, legend=True, fontsize=8, grid=False, figsize=(10,25), linewidth=3)
plt.xticks(rotation=90)
for ax in axes.flatten():
ax.axhline(5000, color='k', linestyle='--')
ax.legend(loc='upper center')
plt.show()
I'm using google colab and pandas.我正在使用谷歌 colab 和熊猫。
You have subplots=True
and all subplots are sharing the same x-axis.您有
subplots=True
并且所有子图都共享相同的 x 轴。 Passing in sharex=False
in the plot.line
method should do the trick.在
plot.line
方法中sharex=False
应该可以解决问题。
You can pass in keyword arguments into DataFrame.plot.line
which are passed onto DataFrame.plot
.您可以将关键字参数传递给
DataFrame.plot.line
,这些参数传递给DataFrame.plot
。 You can check them out in the docs .您可以在文档中查看它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.