简体   繁体   中英

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. How can I show the date below each graph.

It looks like this, but I wan't x axis for all graphs

在此处输入图像描述

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.

You have subplots=True and all subplots are sharing the same x-axis. Passing in sharex=False in the plot.line method should do the trick.

You can pass in keyword arguments into DataFrame.plot.line which are passed onto DataFrame.plot . You can check them out in the docs .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM