How can I use matplotlib or any other library to draw line graphs in Python with highlighted/prominent data points, something like the one shown in the image?
3 Answers
You can create two plots, one for your main data, and the other, with the prominent data points:
import matplotlib.pyplot as plt
#example data below:
main_data = [[45, 23, 13, 4, 5, 66], [33, 23, 4, 23, 5, 56]]
highlight = [[46, 42], [34, 10]]
plt.plot(*main_data)
plt.scatter(*highlight, marker='v', color='r')
2 Comments
I came here because I had a list of the x and y values and was creating a line graph out of it in matplotlib. I simply want the data points to be highlighted as they are in the graph the question shows. The other posts don't give an answer to this.
I was able to solve it by simply adding the marker parameter to the plt.plot statement:
plt.plot(x_values, y_values, marker='o')
P.S. My post is not to answer the OP's question but rather to help anybody else who arrives at this question with the same doubt as me....
