I have created a matplotlib plot based on a pandas dataframe that plots correctly. I am in the process of including vertical lines on the chart. I am able to do that by using this:
permitdate = 'June 15, 2017'
ax.axvline(permitdate, linewidth=2)
Permit date can be any arbitrary date that I want to plot.
The issue I have is that the index (i.e. the x-asix on the chart) is on a month end basis:
DatetimeIndex(['2017-04-30', '2017-05-31', '2017-06-30', '2017-07-31',
'2017-08-31', '2017-09-30', '2017-10-31', '2017-11-30',
'2017-12-31'],
dtype='datetime64[ns]', name='Date', freq=None)
When I try to chart the vlines, it puts the line directly on the month in which the date is.
for example, the permit date from the above shows on top of june x-tick on the a-axis. Is there a way to show it in between the June and July x-ticks that represents it actual place between the months and not directly over the month x axis spot?
Edit:
An example inspired by the pandas docs:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
ts = pd.Series(np.random.randn(10), index=pd.date_range('1/1/2000', periods=10, freq='m'))
ts = ts.cumsum()
df = pd.DataFrame(np.random.randn(10, 4), index=ts.index, columns=list('ABCD'))
df = df.cumsum()
ax = df.plot()
designdate = 'July 15, 2000'
ax.axvline(designdate, linewidth=2)
Thanks,
Ivan
