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

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 12월 22일
편집: Azzi Abdelmalek 2012년 12월 22일

1 개 추천

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

댓글 수: 17

plot(t, y1, 'or', t, y2, '-g')
Sam Alex
Sam Alex 2012년 12월 22일
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 2012년 12월 22일
Maybe you want to, or should, plot the difference instead of the value themselves.
Sam Alex
Sam Alex 2012년 12월 22일
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 2012년 12월 22일
편집: Azzi Abdelmalek 2012년 12월 22일
What do you want exactly to plot? post your two functions
Sam Alex
Sam Alex 2012년 12월 22일
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 2012년 12월 22일
Post a link that contains your file
Image Analyst
Image Analyst 2012년 12월 22일
편집: Image Analyst 2012년 12월 22일
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 2012년 12월 22일
Sorry - Windows doesn't support proprietary .rar files.
Sam Alex
Sam Alex 2012년 12월 22일
This: set(gca,'xscale','log') did not change a thing to the look of the figure
Azzi Abdelmalek
Azzi Abdelmalek 2012년 12월 22일
It's not the same plot
Walter Roberson
Walter Roberson 2012년 12월 22일
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 2012년 12월 22일
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 2012년 12월 22일
편집: Azzi Abdelmalek 2012년 12월 22일
The variation becomes too small, you have to make several plots in many intervals to see these variations
Walter Roberson
Walter Roberson 2012년 12월 22일
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 2012년 12월 22일
Thanks Azzi. You are an A++ expert!

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

José-Luis
José-Luis 2012년 12월 22일
편집: José-Luis 2012년 12월 22일

0 개 추천

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

Sam Alex
Sam Alex 2012년 12월 22일
This does not plot as you say! Where is the line and that you are saying?
José-Luis
José-Luis 2012년 12월 22일
Edited code: I was not plotting a line but points, please look at my updated answer.
Sam Alex
Sam Alex 2012년 12월 22일
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 2012년 12월 22일
Not like that, but plotmatrix() could help you for that.
Sam Alex
Sam Alex 2012년 12월 22일
Thank you so much. You are wonderful!
José-Luis
José-Luis 2012년 12월 22일
Not sure about that, but I'm glad I could help.

댓글을 달려면 로그인하십시오.

John D'Errico
John D'Errico 2012년 12월 22일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by