plot 2 curves with 'very close' y values

Hello,
I would like to know if there is a way in matlab to plot 2 curves on the same plot, that have very close y values (very small differences).
Note: I have tried the 'log' for the y-scale but gave a similar view as the linear!
Thanks

 Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 22 Déc 2012
Modifié(e) : Azzi Abdelmalek le 22 Déc 2012
plot(t,y1,'or)
hold on
plot(t,y2,'-g')

17 commentaires

plot(t, y1, 'or', t, y2, '-g')
Sam Alex
Sam Alex le 22 Déc 2012
Yes but this plots regular graphs, but what I am saying here that they are so close in terms of their y-scale values
Image Analyst
Image Analyst le 22 Déc 2012
Maybe you want to, or should, plot the difference instead of the value themselves.
Sam Alex
Sam Alex le 22 Déc 2012
It wont work since people should see the exact y-axis since it represents the objective function values, and for some problems, the optimal is unknown so we cant do this
Azzi Abdelmalek
Azzi Abdelmalek le 22 Déc 2012
Modifié(e) : Azzi Abdelmalek le 22 Déc 2012
What do you want exactly to plot? post your two functions
Sam Alex
Sam Alex le 22 Déc 2012
How can I paste 2 columns, each containing around 10,000 values? Is there a way to attach files here? Thanks
Azzi Abdelmalek
Azzi Abdelmalek le 22 Déc 2012
Post a link that contains your file
Image Analyst
Image Analyst le 22 Déc 2012
Modifié(e) : Image Analyst le 22 Déc 2012
Have you maximized the height of your axes? To as much as full screen or close to it?
add to your plot
set(gca,'xscale','log')
Image Analyst
Image Analyst le 22 Déc 2012
Sorry - Windows doesn't support proprietary .rar files.
Sam Alex
Sam Alex le 22 Déc 2012
This: set(gca,'xscale','log') did not change a thing to the look of the figure
Azzi Abdelmalek
Azzi Abdelmalek le 22 Déc 2012
It's not the same plot
Walter Roberson
Walter Roberson le 22 Déc 2012
You have not really defined your goal. You know how to plot two lines on the same plot, so you must be talking about something you want to do with the presentation of the lines, but you have not defined what you want the result to be.
Sam Alex
Sam Alex le 22 Déc 2012
It gives a very nice start, but then when they approach the 1.3 they get very similar and again interleaved...any ideas?
Azzi Abdelmalek
Azzi Abdelmalek le 22 Déc 2012
Modifié(e) : Azzi Abdelmalek le 22 Déc 2012
The variation becomes too small, you have to make several plots in many intervals to see these variations
Walter Roberson
Walter Roberson le 22 Déc 2012
Okay, so they get similar and interleaved, and that is a problem because... ? And what would your output look like ideally?
Sam Alex
Sam Alex le 22 Déc 2012
Thanks Azzi. You are an A++ expert!

Connectez-vous pour commenter.

Plus de réponses (2)

José-Luis
José-Luis le 22 Déc 2012
Modifié(e) : José-Luis le 22 Déc 2012
If you want to see the differences and at the same time keep values of your vectors, i would recommend something like this:
plot(x1d,x2d,'b-'); %your values
hold on;
plot([0 3],[0 3], 'k-'); % 1:1 line
So you have both your vectors in the x and y axes, and the diagonal line shows points of equal value. Below the diagonal one is greater than the other. Vice-versa for above. The further away, the larger the difference.

6 commentaires

Sam Alex
Sam Alex le 22 Déc 2012
This does not plot as you say! Where is the line and that you are saying?
José-Luis
José-Luis le 22 Déc 2012
Edited code: I was not plotting a line but points, please look at my updated answer.
Sam Alex
Sam Alex le 22 Déc 2012
This very nice to compare just two plots right? Is there a generalization to compare more than two plots on the same figure?
José-Luis
José-Luis le 22 Déc 2012
Not like that, but plotmatrix() could help you for that.
Sam Alex
Sam Alex le 22 Déc 2012
Thank you so much. You are wonderful!
José-Luis
José-Luis le 22 Déc 2012
Not sure about that, but I'm glad I could help.

Connectez-vous pour commenter.

John D'Errico
John D'Errico le 22 Déc 2012

0 votes

So why not just plot the difference?
Or create two plots as a subplot, one with just curve 1, and the second as the difference between the two curves?
Or, have both plots on the same set of axes, with a double y axis?
help plotyy

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by