How to plot 2 outputs on same graph, challenge is both of them has different xlim and ylim's.

Please open the attached PDF, i have attached the plots and code in there.

5 Comments

What are you expecting to see? It clearly makes no sense to plot something with an x range of -0.2 to 1 on the same axes as something with an x range of 0 to 3000. The first will be totally squashed up if you do.
If there were an xxaxis function in Matlab like the yyaxis then maybe you could do it, but why would it be better than each having their own axes?
HI Adam, that's what i have clearly mentioned in the question that both of them have different x and y limits, yup the first plot is being squashed up because the second plot changes the limits, that's what i want to know is there any way around to do it?
and so that i can get a plot like this, combination of two plots, which i am able to do it in excel
Yes, I understood that your data has different x and y limits. That is why I asked the question. It clearly makes no sense to combine them without additional knowledge that isn't included here. If they have some sense in which they can be overlaid onto each other to make sense as you seem to suggest (though the data in your recently attached plot looks very different from the first) then you can always scale them mathematically to be in the same range before you plot them.
Your attached graph.png implies there is some clear mapping from one to the other so since you know what that mapping is just apply it. Otherwise you would just be arbitrarily positioning one on top of the other based on some contrived limits anyway - e.g. the 2nd plot has values upto ~2700 but the range by default is up to 3000. Where do you expect your -0.2 to 1.2 range to map to this to plot them together. Should 1.2 be mapped onto 2700 or onto 3000 or somewhere else?
yeah, that could be one of the possible way, didn't think that way, Thank you Adam.

Sign in to comment.

Answers (1)

yyaxis left
plot(...)
xlim...
ylim...
yyaxis right
plot (...)
xlim...
ylim...

4 Comments

Hi Madhan,
sort of not working, i have attached the result to the pdf, please find the attached pdf
madhan ravi's reply: provide your code along with datas
please check the attached pdf to the comment, you will find the code.
madhan ravi‘s reply : I can interpret your code and not your pdf plus you didn’t attach excel file.
Here is the data
madhan ravi‘s reply : upload your script file
Hi Madhan, you are not able to understand Pdf? is that what you are saying? and secondly there is Data.xlsx file attached to the comments please check again.
madhan ravi‘s reply : Hi Madhan, you are not able to understand Pdf?
yes because it's not organised , why not upload your script file here ??

Sign in to comment.

Categories

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

Community Treasure Hunt

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

Start Hunting!