

Plot x and y data points using scatter () method. Initialize a variable, n, for number of data points. E.g.: import matplotlib.pyplot ( 1,2,3, 4,5,6,color 'red','green','blue') When you have a list of lists and you want them colored per list. To add a line to a scatter plot using Python's Matplotlib, we can take the following steps Set the figure size and adjust the padding between and around the subplots. Rotation=90, va='bottom', ha='center', annotation_clip=False, arrowprops=arrowprops)Īx0.annotate('BlaBlaBla2', xy=(' 16:30:00', ymax), xytext=(10, 25), textcoords='offset points',Īx0. The normal way to plot plots with points in different colors in matplotlib is to pass a list of colors as a parameter.

ymin, ymax = plt.ylim() find the current limits of the y-axis, ymax is used to position the text.
ADD LINE TO SCATTER PLOT PYTHON CODE
Here is some code showing annotation similar to the requested ones. 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. However, this package has problems with the datetime format somehow. They used the package lineid_plot which can be found here

I would like to have something like shown in this picture 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ĭata = np.array(,Īx0.scatter(x=data,y=data, color='green', marker='.')Īx0.text(' 16:30:00',0.005,'BigNews1',rotation=90,va='top')Īx0.text(' 16:30:00',0.005,'BlaBlaBla2',rotation=90,va='top')Īx0.text(' 16:30:00',0.005,'BigNews3',rotation=90,va='top') 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. Here is the code to plot the data and the vertical line: This vertical line indicates that something happened and I would like to add an annotation to that vertical line. I made a plot of a time-series and added a vertical line.
