python plot higlight markers in different color

I have a scatter plot based on 2 sets of numbers. Now for a certain subset of the x values I want the marker highlighted in a different color. I can provide the x values for highlight in a list.

x= [0.0, 0.1, 0.2, 0.4, 0.5, 0.6, 0.7, 1.0, 1.2]
y= [1.0, 1.1, 1.2, 1.3, 1.1, 1.6, 1.2, 1.0, 1.2]

red= [0.2, 0.5, 1.0]

fig= plt.figure(1)
plt.plot(x,y,'bo')
plt.show()

The markers at 0.2, 0.5, 1.0 should be red. And I would also like lines between the markers.

Your feedback is appreciated.

1 answer

  • answered 2018-02-13 00:21 Pa Wa

    You will need to specify the y coordinates too for the red dots and plot them by adding the following statement before the plt.show()

    plt.plot(red,[1.2,1.1,1.0],'ro-')