I have to following code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#Area Plot
plt.figure(figsize=(15,5))
x=pd.date_range('1992-1-1','2014-12-31',freq='6MS').strftime("%Y-%m").tolist()
y=np.random.uniform(-3, 3 , len(x))
plt.fill_between(x[1:], y[1:], 0, where=y[1:] >= 0, facecolor='red', interpolate=True, alpha=0.7,label='Up')
plt.fill_between(x[1:], y[1:], 0, where=y[1:] <= 0, facecolor='green', interpolate=True, alpha=0.7,label='Down')
plt.show
#plt.savefig('file')
that makes the following figure
However, the x-labels are too many and crowded. When I set an x-limit
plt.xlim(["1990-01","2015-1"])
the plot becomes empty and labels disappear, and when I try to change the labels of the xticks
plt.xticks(["1990","1995","2000","2005","2010","2015"])
it does not work as expected and labels are shifted. I have three questions:
(1) How to show x-labels every year or five years?
(2) How to show x-ticks every 6 months or every year?
(3) How to set the xlim from 1993 to 2015 ?