I made a plot of a time-series and added a vertical line. This vertical line indicates that something happened and I would like to add an annotation to that vertical line. But I have no idea how to do this :/
Here is the code to plot the data and the vertical line:
I adjusted the example code which now contains data (although they are somehow weird, but show the problem: The notations at the vertical lines should be above the plot area, and two of the text boxes are now overlapping. This overlapping should be avoided by aranging them differently and using dashed lines or something to point to the vertical line where the text belongs to
%matplotlib inline
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
data = np.array([['2017-07-01 16:30:00', '2017-07-02 16:30:00', '2017-07-03 16:30:00', '2017-07-04 16:30:00', '2017-07-05 16:30:00', '2017-07-06 16:30:00'],
[1.4, 1.3, 2, 0.5, 0.002337, 3 ]])
fig2 = plt.figure(figsize=(16,9))
# TRAIN NORTH
ax0 = fig2.add_subplot(111)
ax0.scatter(x=data[0],y=data[1], color='green', marker='.')
#ax0.legend(df.iloc[0,0],loc='best')
#ax0.set_ylim(0,0.006)
# vertical lines when something happened
ax0.axvline('2017-07-02 16:30:00', color='green')
ax0.axvline('2017-07-02 16:30:00', color='green')
ax0.axvline('2017-07-05 16:30:00', color='green')
ax0.text('2017-07-02 16:30:00',0.005,'BigNews1',rotation=90,va='top')
ax0.text('2017-07-02 16:30:00',0.005,'BlaBlaBla2',rotation=90,va='top')
ax0.text('2017-07-05 16:30:00',0.005,'BigNews3',rotation=90,va='top')
I would like to have something like shown in this picture
They used the package lineid_plot which can be found here
However, this package has problems with the datetime format somehow. I am really sorry for this bad example code shown here, but I am really a beginner and I hope somebaody can help to solve my problem.