help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple Time Formatted Plot Problem


From: Andreas Weber
Subject: Re: Simple Time Formatted Plot Problem
Date: Sun, 4 Mar 2018 11:30:44 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

Am 02.03.2018 um 17:14 schrieb Fritz Sonnichsen:
> I have played with this for a while. I have been able to plot time
> series data in the past but now something has gone wrong. I have
> distilled the problem into the short stretch of code below. The data
> plots without specifying the time axis, but when I add the time
> formatted axis it look find but the data does not appear.
>   Any ideas?
> Thanks
> Fritz
> ======================= CODE ===========================
> 1;
> clear all
> fflush(stdin);
> 
> xtme=["12:20:39";"12:20:41";"12:20:42";"12:20:43";"12:20:44"];
> xT=[    1      ;2       ;3       ;4       ;5];
> 
> 
> plot(xT)
> figure
> timeFormat='HH:MM:SS';
> xdatenum=datenum(xtme,timeFormat); %days from January 0, 0000
> xlen = length(xtme);
> plot(xdatenum,xT,'color','r');
> datetick('x',timeFormat,'keepticks')
> axis([0 xlen 0  10])
>     return

I normally set the timeticks manually:

clear all

xtme=["12:20:39";"12:20:41";"12:20:42";"12:20:43";"12:20:44"];
xT=[    1      ;2       ;3       ;4       ;5];

timeFormat='HH:MM:SS';
xdatenum=datenum(xtme,timeFormat); %days from January 0, 0000

plot (xT, 'color', 'r');

## make sure xticks are valid indexes
set (gca, "xtick", round (get (gca, "xtick")))

## set xticklabels manually
set (gca, "xticklabel", datestr (xdatenum, timeFormat))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]