Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get 3 plots on the same graph using the same axes?

Status
Not open for further replies.

bluemood

Specifier/Regulator
Dec 11, 2002
5
Hello there,

I am a beginner on MATLAB. Facing problem to get 3 plots using the same axes. Hope my note is understandable .....

Here's the scenerio.

I have 3 column vectors of same certain length - A, B, C. C contains 3 discrete values - aa, bb, cc. At any one time, aa, bb, cc can have the same A & B.

I want to compare the 3 different values of C by different colours on the same graph with A & B as the x-y axes.

Using plot(A, B, 'r*') can give me what I required but w/o the 3 different colours of C.

Can someone help me on this?

Many thanks in advance!
 
Replies continue below

Recommended for you

plot(A,B,aa,'r*') % plot will be red

hold on % allows adding overplots

plot(A,B,bb,'b*') % plot will be blue
plot(A,B,cc,'c*') % plot will be cyan


 
Thanks, Lewish.

I put in the aa value but the command won't work.

??? Error using ==> plot
String argument is an unknown option.

Error in ==> D:\csv1.m
On line 21 ==> plot(c, s, 0, 'r*');
 
Oops, I misread part of your post. I incorrectly assumed that aa was a separate value set to C at some time, then bb, etc.

What I need to know, to be of further help, is how are aa, bb, and cc contained in C? Are they as an array or as a struct?

Figure out how to access those values, and then replace that addressing with the aa, bb, and cc in the previous example. Then you should get your plot.

 
Hi Lewish,

Thanks so much for your help.

aa, bb, cc is stored as array.

Took me quite a while and I managed to access aa, bb, cc. I sort them out and plot them by calling aa to plot with A & B, calling bb to plot with A & B and so on... with hold on. This way, I get the aa, bb, cc to plot on the same A & B axes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor