MATLAB - Plot multiple data sets on a scatter plot

Mark picture Mark · Mar 20, 2010 · Viewed 91.7k times · Source

I have two sets of data, (Ax, Ay; Bx, By). I'd like to plot both of these data sets on a scatter plot with different colors, but I can't seem to get it to work, because it seems scatter() does not work like plot(). Is it possible to do this?

I've tried...

scatter(Ax, Ay, 'g', Bx, By, 'b')

And

scatter(Ax, Ay, 'g')
scatter(Bx, By, 'b')

The first way returns an error. The latter only plots the Bx/By data.

Answer

Qtax picture Qtax · Mar 20, 2010

Try using hold on with the second example.