How to plot a specific data with different color in Python, matplotlib

Viewed 42

The code below plots the gauss function in a graph.

And I want the center in the code presents in different color.

Is there any approach I can do?

plt.figure(figsize = (15,15))

plt.grid(True)

x = np.linspace(0,11, 100)
center = np.mean(x)
print(center) # This is the only point what I would like to give different color
gauss_function = np.exp(-((x-center)**2)/2**2)
plt.plot(x, gauss_function, marker='o')

enter image description here

Thank you so much for your time !

1 Answers

This works

# compute red point coordinates
point_x = center
point_y = np.exp(-((center-point_x)**2)/2**2)

plt.scatter(point_x, point_y, marker='o', color='red', s=50, zorder=3)

where s=50 defines the size of the red marker, while zorder=3 is used to put the red marker over the current (Gaussian) graph

Related