Interpretting plot of two vectors as "multiline plot" with just point each in each plot?

Interpretting plot of two vectors as "multiline plot" with just point each in each plot?

Post by A » Thu, 25 Mar 2010 02:17:25


Hi,

When we apply the plot command to two matrices X and Y of equal size, matlab constructs a plot for every pair of corresponding columns in the two matrices, and assigns colors to the plots according the order specified in the ColorOrder property of the axes. eg:

t = [0:0.01:1]';
rad = [1 2 3 4];
X = cos(2*pi*t)*rad;
Y = sin(2*pi*t)*rad;
plot(X,Y, '*')

If X and Y are vectors instead of matrices, matlab always interprets them as consituting the points of a single plot, no matter whether X and Y are row or column vectors.
Is there any (proper) way to force matlab to interpret X and Y as containing multiple plots with one point each (plotting them according to ColorOrder, which is important to me)?
i.e. if
X = [1 2 3 4]; Y = [6 7 8 9];
then (1,1), (2,2), (3,3) and (4,4) are four "plots" with one point each, and plotted with colors defined by ColorOrder?

Besides a hack consisting of adding a row of zeros to the bottom of X and Y making them into a matrices (then ignoring (0,0) which i know not to be actual data)
I tried

figure; hold on;
X = num2cell(X), Y = num2cell(Y);
plot(X{:}, Y{:}, '*');

which nearly works, but the style property '*' is applied only to the last plot, leaving the first 3 plots nearly invisible.
I realise I could also do it manually by plotting one point at a time and iterating through ColorOrder, but that seems tacky as well.

Any ideas?
 
 
 

Interpretting plot of two vectors as "multiline plot" with just point each in each plot?

Post by Steven Lor » Thu, 25 Mar 2010 02:24:51


You should use SCATTER instead.

--
Steve Lord
XXXX@XXXXX.COM
comp.soft-sys.matlab (CSSM) FAQ: http://www.yqcomputer.com/