Display data points in python using pylab

enter image description here I have data that I need to build

X = [0,1,2,3,4,5] Y = [6,7,8,9,10,11,12,13,14,15]

X belongs to class 1, so I would like them to be highlighted in green, and Y belongs to class2, so I would like them to be built in blue.

What I've done,

import pylab as pl
pl.plot(X,'go')
pl.plot(Y,'bo')
pl.show()

But this is graph X versus Y. All I want to display on my graph is just the X and Y points in green and blue, respectively.

How can i do this?

+5
source share
1 answer

X Y, , X Y . say x - ( ) y ( ). pl.plot(x,y), x y - . , , y, matplotlib x, :

import pylab as pl

y1 = [0,1,2,3,4,5] 
y2 = [6,7,8,9,10,11,12,13,14,15]

x1 = range(len(y1))
x2 = range(len(y2))

pl.plot(x1, y1,'go')
pl.plot(x2, y2,'bo')
pl.show()

, , x.

+2

All Articles