Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: plotyy axis auto
Replies: 0

 RICARDO Posts: 5 Registered: 12/6/12
plotyy axis auto
Posted: Oct 17, 2013 8:49 AM

I plotted two sets of data y with the same x. I would like to make the axis auto in order to get a tight plot.
Here is my code:

clc;clear all;%close all;
fconversion = 10^6*0.000621371;
% read labels and x-y data
[soot,tTMAT,tPAX,extTMT,extPAX,eSca]=textread('041713','%d %s %s %f %f %f');
t_tm = datenum(datevec(tTMAT,'HH:MM'));
t_tceq0319 = datenum(datevec(t_vis_airport,'HH:MM'));
visTMT = zeros(size(extTMT));
visTMT = (3.912*fconversion./extTMT')';
fig = figure;
set(fig,'units','normalized','outerposition',[0 0 1 1]);
[ax,H1,H2]=plotyy(t_tm,visTMT,t_tm,vis_airport,'plot');
for i=1:2
datetick(ax(i),'x', 15) % look up datetick in help to get more info on the 2nd argument
% axis auto;
end
set(get(ax(1),'Ylabel'),'String','Model (mi)');
set(get(ax(2),'Ylabel'),'String','Airport (mi)');
xlabel('Local time');
title({'April 17, 2013'});

%%%%%%%%%%%%%%%%%%%
end of matlab code
%%%%%%%%%%%%%%%%%%%
"file 041713"

4 13:27 13:27 179.23801 179.28810 0.05009
2 15:12 15:12 314.89700 315.15451 0.25751
2 15:27 15:27 303.63199 303.60461 0.02737
4 16:42 16:42 421.10101 421.03381 0.06720
2 16:57 16:57 309.84399 310.53610 0.69211
1 17:27 17:27 314.35501 315.49200 1.13699
3 17:42 17:42 358.78900 359.10019 0.31119
3 17:57 17:57 342.25699 342.71390 0.45691
0 18:57 18:57 329.47000 330.55490 1.08490
6 19:42 19:42 403.23801 402.08551 1.15250

"file air_041713"

13:27 1.25
15:12 1.25
15:27 1.15
16:42 2.48
16:57 2.50
17:27 2.50
17:42 2.50
17:57 2.50
18:57 2.60
19:42 3.70

If you plot my code you will see what I am talking about.