


TIMEPLT time series stack plots with Gregorian Time labels on x axes
USAGE:
h = timeplt ( 'demo' )
where
h = handles of plot axes
h = timeplt ( jd, u, [istack], [ylims] );
where
jd = Julian Day time vector (e.g produced by JULIAN.M)
u = column vector or matrix of column vectors containing time
series data. If the column is complex, it will be plotted
as a stick plot.
istack = vector of indices indicating which panel you want
to plot the time series data. istack=[1 2] would make
two panels one on top of the other and plot the first
column of u in the lower panel and the second column of
u in the upper panel. If any column in u is complex,
istack must be specified. If istack is not specified, all the
columns will be plotted in the first panel.
ylims = [npanels x 2] matrix containing the ylimits of
the panel plots. If you are plotting two panels and
you want the limits of both plots to be from -10 to 15,
then set ylims=[-10 15; -10 15]. Autoscales if ylims
is not set

0001 function h = timeplt ( arg1, arg2, arg3, arg4 ) 0002 % TIMEPLT time series stack plots with Gregorian Time labels on x axes 0003 % 0004 % USAGE: 0005 % h = timeplt ( 'demo' ) 0006 % 0007 % where 0008 % h = handles of plot axes 0009 % 0010 % h = timeplt ( jd, u, [istack], [ylims] ); 0011 % 0012 % where 0013 % jd = Julian Day time vector (e.g produced by JULIAN.M) 0014 % u = column vector or matrix of column vectors containing time 0015 % series data. If the column is complex, it will be plotted 0016 % as a stick plot. 0017 % istack = vector of indices indicating which panel you want 0018 % to plot the time series data. istack=[1 2] would make 0019 % two panels one on top of the other and plot the first 0020 % column of u in the lower panel and the second column of 0021 % u in the upper panel. If any column in u is complex, 0022 % istack must be specified. If istack is not specified, all the 0023 % columns will be plotted in the first panel. 0024 % ylims = [npanels x 2] matrix containing the ylimits of 0025 % the panel plots. If you are plotting two panels and 0026 % you want the limits of both plots to be from -10 to 15, 0027 % then set ylims=[-10 15; -10 15]. Autoscales if ylims 0028 % is not set 0029 % 0030 0031 % 0032 % directory of data structure fields 0033 % 0034 % [year|month|day|hour|minute]_cut 0035 % Set the cutoff for different types of Gregorian axis types 0036 % You can adjust these to suit your preferences. For example, 0037 % if your plot got labeled with days, but you want hours, 0038 % run timeplt again with hour_cut specified. 0039 % 0040 % [year|month|day|hour|minute]_cut_flag 0041 % If any of these are true, then the plot follows that convention. 0042 % 0043 % figure: 0044 % handle for the time plot figure window 0045 % jd: 0046 % julian time vector for the given plots 0047 % data: 0048 % stuff to be plotted vs time 0049 % plot_axes: 0050 % vector of axes handles. They correspond to what's in "istack". 0051 % If istack was not specified, then there is just one axes. Same 0052 % as output h above. 0053 % istack: 0054 % Same as above. 0055 % ylims: 0056 % Same as above. 0057 % 0058 0059 0060 global timeplt_obj timeplt_count; 0061 0062 % 0063 % keep track of how many timeplt objects are active. 0064 if ( size(timeplt_count,1) > 0 ) 0065 timeplt_count = timeplt_count + 1; 0066 else 0067 timeplt_count = 1; 0068 end 0069 0070 N = timeplt_count; 0071 0072 0073 % 0074 % Store default values. 0075 timeplt_obj{N}.year_cut=250; 0076 timeplt_obj{N}.month_cut=20; 0077 timeplt_obj{N}.day_cut=.2; 0078 timeplt_obj{N}.hour_cut=.02; 0079 timeplt_obj{N}.minute_cut=0.005; 0080 0081 timeplt_obj{N}.year_cut_specified = 0; 0082 timeplt_obj{N}.month_cut_specified = 0; 0083 timeplt_obj{N}.day_cut_specified = 0; 0084 timeplt_obj{N}.hour_cut_specified = 0; 0085 timeplt_obj{N}.minute_cut_specified = 0; 0086 0087 timeplt_obj{N}.plot_axes = []; 0088 timeplt_obj{N}.ylims = []; 0089 0090 0091 % 0092 % Store a reference to the figure window. 0093 % If there are any open figures, use it. 0094 timeplt_obj{N}.figure = timeplt_figure(gcf, N); 0095 0096 0097 % 0098 % Catch resize events in the figure, and don't clip the data! 0099 set ( timeplt_obj{N}.figure, ... 0100 'ResizeFcn', 'timeplt_draw', ... 0101 'DefaultLineClipping', 'off' ); 0102 0103 0104 0105 % 0106 % Parse the command line args. 0107 if ( nargin == 0 ) 0108 0109 disp ( 'No arguments specified.' ); 0110 help timeplt; 0111 delete ( timeplt_obj{N}.figure ); 0112 return; 0113 0114 end 0115 0116 if ( nargin == 1 ) 0117 0118 if ( strcmp(arg1, 'demo') ) 0119 0120 start=[1990 11 1 0 0 0]; %Gregorian start [yyyy mm dd hh mi sc] 0121 stop=[1991 2 1 0 0 0]; 0122 jd=julian(start):julian(stop); 0123 u=sin(.1*jd(:)).^2-.5; 0124 v=cos(.1*jd(:)); 0125 0126 % 0127 %w is vector, so must have it's own axes 0128 w=u+i*v; 0129 0130 timeplt_obj{N}.jd = jd; 0131 timeplt_obj{N}.data = [u v abs(w) w]; 0132 timeplt_obj{N}.istack = [1 1 2 3]; 0133 0134 timeplt_draw; 0135 0136 h = timeplt_obj{N}.plot_axes; 0137 0138 axes ( h(3) ); 0139 title('Demo of Timeplt') 0140 stacklbl( h(1), 'East + North velocity','m/s'); 0141 stacklbl( h(2), 'Speed','m/s'); 0142 stacklbl( h(3), 'Velocity Sticks','m/s'); 0143 0144 set ( h, 'Box', 'on' ); 0145 0146 return; 0147 0148 else 0149 disp ( sprintf ( 'Huh? I don''t recognize %s.', arg1 ) ); 0150 help timeplt; 0151 return; 0152 end 0153 0154 0155 % 0156 % Not a demo, must process the command line arguments. 0157 else 0158 0159 0160 0161 % 0162 % process the first two arguments. 0163 timeplt_obj{N}.jd = arg1(:); 0164 data = arg2; 0165 0166 % 0167 % make sure the data is columar 0168 [r,c] = size(data); 0169 if ( r < c ) 0170 data = data'; 0171 end 0172 timeplt_obj{N}.data = data; 0173 0174 0175 0176 0177 0178 if ( nargin == 2 ) 0179 0180 timeplt_obj{N}.istack = ones(size(timeplt_obj{N}.data,2),1); 0181 timeplt_obj{N}.ylims = []; 0182 0183 elseif ( nargin == 3 ) 0184 0185 timeplt_obj{N}.ylims = []; 0186 timeplt_obj{N}.istack = arg3; 0187 0188 0189 elseif ( nargin == 4 ) 0190 0191 timeplt_obj{N}.istack = arg3; 0192 timeplt_obj{N}.ylims = arg4; 0193 0194 end 0195 0196 end 0197 0198 0199 timeplt_draw; 0200 0201 h = timeplt_obj{N}.plot_axes; 0202 0203 set ( h, 'Box', 'on' ); 0204 0205 0206 % 0207 % Store the ylims so that any plot window resizes 0208 % keep the same ylims. 0209 ylims = []; 0210 for i = 1:length(h) 0211 ylims = [ylims; get(h(i),'YLim')]; 0212 end 0213 timeplt_obj{N}.ylims = ylims; 0214 0215 return; 0216 0217