Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using Matplotlib how to highlight one point in the final plot

Suppose, I have x = [1,2,3,4,5,6] and the corresponding y = [3,4,5,6,7,8].

I want the first pair (1,3) to be in a different color or shape.

How can this be done using python?

like image 856
Abhinav Goel Avatar asked Jan 05 '17 16:01

Abhinav Goel


People also ask

How do I highlight a specific point in matplotlib?

Matplotlib has a function named annotate() to add text in a specific location in a plot. We need to specify annotate() function the text we want to annotate the plot with and the x and y co-ordinates for the location of the text.


1 Answers

One of the simplest possible answers.

import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [3,4,5,6,7,8]

plt.plot(x[1:], y[1:], 'ro')
plt.plot(x[0], y[0], 'g*')

plt.show()
like image 157
Bill Bell Avatar answered Sep 28 '22 08:09

Bill Bell