|
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
|