×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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!

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

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


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

(OP)
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*');

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

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.

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

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources