2-x axes and 1-y axis
5 次查看(过去 30 天)
显示 更早的评论
I would like to plot a figure having two x-axes at the bottom and the top of the figure, and one y-axis at the left of the figure.
I did an experiment where I am finding the relation between Intensiy and (time or temperature)
So I would like to have the time on the bottom x-axis and the corresponding temperature on the top x-axis. Where the intensity is common for both on the left y-axis.
Data as an example:
% Time in seconds
Time=[1 2 3 4 5 6 7 8 9 10]
Temperature=[23 10 0 -5]
Intensity=[2 2 4 3 7 9 5 6 8 2]
% where the temperature readings correspond to Time=[1 4 7 10] and Intensity=[2 3 5 2]
7 个评论
dpb
2019-6-6
Then just reverse the direction for it...
hAx(2).XDir='reverse';
where hAx(2) is the handle to the second x-axis, presumed to be the target desired. You'll have to use whatever handle is the correct variable in your code that we've seen none for--hence the guessing about what you're trying to accomplish.
Or, of course, you can set addtiional parameters at the time you create the axes itself.
回答(1 个)
Jos (10584)
2019-6-6
What about 'abusing' plotyy?
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
plotyy(x, y1, x, y2)
view(90, 90) % a single axis on the left, and two axes on top and bottom
10 个评论
dpb
2019-6-7
Actually, I have a limited number of readings corresponding to {Temperature,Intensity}.
While I have thousands for {Time,Intensity} and I am gothering them together from seperate videos.
So I can reverse the data on the top x-axis easily.
Thank you very much!
dpb
2019-6-7
It still shouldn't make any difference at all how many variables there are -- the reverse direction is a property of the axis, not the data. Set it once and it's set for good...
We've possibly got a language barrier here in not following what you're trying to express...
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Two y-axis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!