2-x axes and 1-y axis

5 views (last 30 days)
Mohammed Qahosh
Mohammed Qahosh on 6 Jun 2019
Commented: dpb on 7 Jun 2019
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 Comments
Mohammed Qahosh
Mohammed Qahosh on 6 Jun 2019
No. In fact the y-axis is the Intensity.
So, I am talking about the top x-axis (Temperature). I want it to be decreasing while moving to the right starting from 23 and ending with -172
dpb
dpb on 6 Jun 2019
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.

Sign in to comment.

Answers (1)

Jos (10584)
Jos (10584) on 6 Jun 2019
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 Comments
dpb
dpb on 7 Jun 2019
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
dpb on 7 Jun 2019
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...

Sign in to comment.

Categories

Find more on Two y-axis 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!