|
"Fiona Buckley" <buckley_fiona@yahoo.com> wrote in message
news:gjvcqj$73t$1@fred.mathworks.com...
> "Steven Lord" <slord@mathworks.com> wrote in message
> <gjt6k8$ms2$1@fred.mathworks.com>...
>>
>> "Fiona Buckley" <buckley_fiona@yahoo.com> wrote in message
>> news:gjsk2h$h31$1@fred.mathworks.com...
>> > "Phil Goddard" <philgoddardNOSPAM@telus.net> wrote in message
>> > <gjmo95$82s$1@fred.mathworks.com>...
>> >> Have you tried
>> >> datetick('x','keepticks')
>> >> option?
>> >>
>> >> Phil.
>> >
>> > If I do this, I only get the time and no longer the date and the time
>> > on
>> > my x axis and in addition to this I cannot set the ticks at the desired
>> > spacing (in this case 10minutes)
>> >
>> > Any other ideas?
>>
>> Is this more like what you want?
>>
>>
>> % Create a vector of datenums -- every ten minutes starting now and
>> ending
>> tomorrow
>> x = linspace(now, now+1, 24*6+1);
>>
>> % Verify that the datenums in x represent ten-minute intervals
>> datestr(x)
>>
>> % Create a sample plot
>> plot(x, (1:length(x)).^2);
>>
>> % Set the ticks to appear every hour
>> set(gca, 'XTick', x(1:6:end));
>>
>> % Call DATETICK with a date format (to display just the hour and minute,
>> with AM/PM)
>> % and keep the existing tick locations
>> datetick('x', 'HH:MM PM', 'keepticks')
>>
>>
>> The ticks are going to be closely spaced, so you may need to maximize the
>> figure to see them all. Just adjust the 6 in the next-to-last line to
>> change the spacing of the ticks if you want.
>>
>> --
>> Steve Lord
>> slord@mathworks.com
>>
>
> Hi again,
> sorry but this is not really what I'm looking for...
> I have data that is collected every minute over a time period of several
> months. To facilitate things, I converted my 2 "date & time columns" in a
> single one using datenum (My x axis - time - is therefore in Matlab
> datenum format). I broke down the data and am plotting a graph every four
> hours.
> What I want to do is :
> 1- On the graph have the x data labelling back in "real time" (date and
> HH:MM:SS). For that I need to use datetick
> 2- Set the ticks on the x axis to be every 10minutes in order to see
> progression over time and have a 10 minute grid on the graph. For this I
> need set axis.
> However, I can't seem to be able to use BOTH functions in my script. If I
> use both, only one (datetick) has impact on my graph (and this no matter
> the order) but if I only encode either of the two, whichever one it is has
> an impact on the graph.
What you've described is pretty much _exactly_ what I did above, modulo the
fact that I only used 'HH:MM PM' as the date format (and assuming you add
"grid on" after the DATETICK call.) The next-to-last line of code sets the
ticks to be every ten minutes (your requirement 2) and the last line of code
sets the tick labels to be date strings (your requirement 1). The
'keepticks' parameter in the DATETICK call forces DATETICK to use the ticks
that I set on the next-to-last line and to just change the tick labels.
Can you clarify what additional requirements you have that this code does
not satisfy?
--
Steve Lord
slord@mathworks.com
|