Re: can matlab plot data by condition
- From: virtualcyberinfo@xxxxxxxxx
- Date: Wed, 31 Oct 2007 08:56:42 -0700
On 10 31 , 9 30 , "Diederick Niehorster" <n...@xxxxxxxx> wrote:
"Ha Wanger" <virtualcyberinfo+nos...@xxxxxxxxx> wrote in
message <fg98ea$iv...@xxxxxxxxxxxxxxxxxx>...
I have two matrix like these:
X = [1 2 3 4 5 6]
Y = [-3 -1 -2 2 -1 1]
I want to have a line-dot plot and when Y<0, the dot isred;
when Y>0, the dot is blue.
Now I'm using the follwing method:
1. creat two matrixs foo1 & foo2 from [X;Y]
foo1 = [1 2 3 5 ; -3 -1 -2 -1]
foo2 = [4 6 ; 2 1]
2. plot(foo1(1,:),foo1(2:,),'.r')
plot(foo2(1,:),foo2(2:,),'.b')
plot(X,Y,'-')
actually,the matrixs X & Y are very big so this method is
some inefficient.
Can anyone give me a better method? Thanks!
I think the easiest way is to plot the line and the dots
seperately:
X = [1 2 3 4 5 6];
Y = [-3 -1 -2 2 -1 1];
plot(X,Y,'k-');
hold on;
plot(X(Y<0),Y(Y<0),'ro');
plot(X(Y>=0),Y(Y>=0),'bo');
enjoy ;)- -
- -
Good! it works
.
- References:
- can matlab plot data by condition
- From: Ha Wanger
- Re: can matlab plot data by condition
- From: Diederick Niehorster
- can matlab plot data by condition
- Prev by Date: Re: Printing large figure to file
- Next by Date: Re: How to create movie from bitmap images?
- Previous by thread: Re: can matlab plot data by condition
- Next by thread: Primitive polynomial over/of GF(p^m)
- Index(es):