Speichern Sie Datumszeichenfolgen in Array b in "moderaten Intervallen" und setzen Sie sie mit set_xticklabels
hoge.py
import numpy as np
import matplotlib.pyplot as plt
ax = df.plot(kind='bar', color=['b','r','g'] , label ='hoge' ,alpha=0.3 )
#ax = plt.gca()
ln = len(df.index)
a = np.arange(ln)+1
b = []
for i in a-1:
b.append("") if i%5!=0 else b.append(str(df.index[i].strftime('%m/%d')))
#print(b)
ax.set_xticklabels(b,rotation =15)
Die X-Achsen-Notation wird mit ax.xaxis.set_major_formatter usw. festgelegt.
hoge.py
ax = df.plot(kind='line', color=['b','r','g'] , label ='hoge' ,alpha=0.3 )
years = mdates.MonthLocator(interval=3)
months = mdates.MonthLocator()
daysFmt = mdates.DateFormatter("%m/%d")
ax.xaxis.set_major_locator(years)
ax.xaxis.set_minor_locator(months)
ax.xaxis.set_major_formatter( daysFmt )
Recommended Posts