Thread Subject: plotting data and time

Subject: plotting data and time

From: sujata

Date: 23 Dec, 2008 08:14:03

Message: 1 of 1

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

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
plot sujata 23 Dec, 2008 03:15:10
rssFeed for this Thread

Contact us at files@mathworks.com