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

 Accepted Answer

plot(t,y1,'or)
hold on
plot(t,y2,'-g')

17 Comments

plot(t, y1, 'or', t, y2, '-g')
Yes but this plots regular graphs, but what I am saying here that they are so close in terms of their y-scale values
Maybe you want to, or should, plot the difference instead of the value themselves.
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
What do you want exactly to plot? post your two functions
How can I paste 2 columns, each containing around 10,000 values? Is there a way to attach files here? Thanks
Post a link that contains your file
Image Analyst
Image Analyst on 22 Dec 2012
Edited: Image Analyst on 22 Dec 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')
Sorry - Windows doesn't support proprietary .rar files.
This: set(gca,'xscale','log') did not change a thing to the look of the figure
It's not the same plot
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.
It gives a very nice start, but then when they approach the 1.3 they get very similar and again interleaved...any ideas?
The variation becomes too small, you have to make several plots in many intervals to see these variations
Okay, so they get similar and interleaved, and that is a problem because... ? And what would your output look like ideally?
Thanks Azzi. You are an A++ expert!

Sign in to comment.

More Answers (2)

José-Luis
José-Luis on 22 Dec 2012
Edited: José-Luis on 22 Dec 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 Comments

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

Sign in to comment.

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

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!