Path: news.mathworks.com!not-for-mail
From: "sujata" <sujatagp@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: plotting data and time
Date: Tue, 23 Dec 2008 08:14:03 +0000 (UTC)
Organization: erasmus university
Lines: 26
Message-ID: <giq6kb$qrj$1@fred.mathworks.com>
Reply-To: "sujata" <sujatagp@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1230020043 27507 172.30.248.35 (23 Dec 2008 08:14:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 23 Dec 2008 08:14:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1418531
Xref: news.mathworks.com comp.soft-sys.matlab:508456


Hi,

I have some data for which I need to plot the the date in format dd/mm/yyyy on the x-axis in a graph in a GUI. 

So far I did the following which kinda works:
after I plotted the data I made a label vector:

alldates =['30/09/2007' '31/10/2007'  etc until '31/11/2008' ] 

The all dates vector is quite long, it has a size of like 76 by 1. I do not need to plot all the 76 labels on the x-axis since it doesn't fit, so I made 7 equal spaces like the following.

Spaces = floor(linspace(1,size(alldates,1),7));
adjusted = alldates(Spaces,1) --> this selects the relevant dates for my axis
set(axes_handles,'XTickLabel',adjusted);
set(axes_handles,'XTick', Spaces);

When I run the code, it works perfectly, except for one problem. When the data is plotted at the end of the graph there is a empty gap between the axis limits and the data. I used axis tight to set the axis limit to fit the range of the data but then my labels do not match the correct datapoints in the graph. 

I hope I described the problem as clearly as possible. Can someone help me how to match it nicely and correctly put my labels.

Thanks in advance
Sujata