Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: Change the x-axis scale on a graph
Posted:
Feb 5, 2013 5:34 AM
|
|
Dear dpb, sorry for being late and thanks!!!! Best, M
dpb <none@non.net> wrote in message <kem0ib$g2m$1@speranza.aioe.org>... > On 2/3/2013 5:40 AM, Milos Milenkovic wrote: > > Dear, I have a special time series graph. It's looks as follows: > > a = [1 431.3 0.5 454 1 476.7; > > 2 412.3 1.5 434 2 455.7]; > > x = a(:,[1 3 5])'; > > y = a(:,[2 4 6])'; > ... > > > > > How to transform the scale of x axis? In particular case I want to > > change the values 0,1,2,3,4 with Dec 2005, Jan 2006, Feb 2006, ..... > > yr=2005; % beginning year > mo=[12:28]; % a vector of months > da=1; % day > x_dat=datenum(y,mo',d); % convert to datenums > plot(x_dat,rand(size(x_dat))) % sample data plot > datetick('x','mmmyy','keeplimits','keepticks') % display as dates > > NB: datenum() and friends will roll months,days over to next using > calendar arithmetic so that 2005-13-01 becomes 2006-01-01. Thus you can > simply create the date range by passing the start year and a vector of > months from first incrementing by 1 to whatever final length you wish. > I just used a number here great enough to show a couple of years for > demo purposes... > > Adjust final limits as per your desires for presentation--you can set > fixed tick values, etc., either by axes([]) or directly w/ set()... > > doc datenum % and friends > doc datetick > > --
|
|
|
|