Problem plotting time on X axis

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem plotting time on X axis

Fritz Sonnichsen
Octave 4.0.0
I am trying to plot a time series data. I found some examples and tried
them but they don't seem to work. I have data as shown:
9:00:38      23.9
9:00:39      23.9
.....

My code looks like this:
[dtmeT, T] = textread (filenameT, "%s %f");  %read in the data
    timeFormat='HH:MM:SS';
   ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
   plot(ser_date,T ,'color','k'  );
   datetick('x',timeFormat,'keepticks')
   xlen = length(dtmeT)  ;
   axis([0 xlen 20 35])

I get a time labeled axis as expected, but I do not see the plot of T.  
The data is valid-if I plot it without time formatting it works fine.

thanks
fritz



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Problem plotting time on X axis

Przemek Klosowski-7
On 02/14/2018 02:00 PM, Fritz Sonnichsen wrote:
> ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
>   plot(ser_date,T ,'color','k'  );
>   datetick('x',timeFormat,'keepticks')
>   xlen = length(dtmeT)  ;
>   axis([0 xlen 20 35])

I think it's a manifestation of the magnitude bug in the default toolkit
(fltk?). The problem is that fltk can't plot intervals that have a short
span compared to the magnitude of the endpoints. Since you don't seem to
care about the actual date,  resetting the beginning to midnight works
around that:

plot(ser_date-datenum("00:00:00"),T ,'color','k' )



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Problem plotting time on X axis

Fritz Sonnichsen
I tried that and it did not work.  My "ser_date" is numbers like:
7.3706e+005

THanks
fritz

On 2/14/2018 2:25 PM, Przemek Klosowski wrote:

> On 02/14/2018 02:00 PM, Fritz Sonnichsen wrote:
>> ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
>>   plot(ser_date,T ,'color','k'  );
>>   datetick('x',timeFormat,'keepticks')
>>   xlen = length(dtmeT)  ;
>>   axis([0 xlen 20 35])
>
> I think it's a manifestation of the magnitude bug in the default
> toolkit (fltk?). The problem is that fltk can't plot intervals that
> have a short span compared to the magnitude of the endpoints. Since
> you don't seem to care about the actual date,  resetting the beginning
> to midnight works around that:
>
> plot(ser_date-datenum("00:00:00"),T ,'color','k' )
>
>
>
> -----------------------------------------
> Join us March 12-15 at CERN near Geneva
> Switzerland for OctConf 2018.  More info:
> https://wiki.octave.org/OctConf_2018
> -----------------------------------------



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Problem plotting time on X axis

Ian McCallion
In reply to this post by Fritz Sonnichsen
Are you sure all the dates are valid and in a sensible range?

On 14 Feb 2018 7:01 pm, "Fritz Sonnichsen" <[hidden email]> wrote:
Octave 4.0.0
I am trying to plot a time series data. I found some examples and tried them but they don't seem to work. I have data as shown:
9:00:38      23.9
9:00:39      23.9
.....

My code looks like this:
[dtmeT, T] = textread (filenameT, "%s %f");  %read in the data
   timeFormat='HH:MM:SS';
  ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
  plot(ser_date,T ,'color','k'  );
  datetick('x',timeFormat,'keepticks')
  xlen = length(dtmeT)  ;
  axis([0 xlen 20 35])

I get a time labeled axis as expected, but I do not see the plot of T.  The data is valid-if I plot it without time formatting it works fine.

thanks
fritz



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------


-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Problem plotting time on X axis

Fritz Sonnichsen
Thanks Ian.
The seem to be in proper sequence. I am not asking you to do my work but to see this it may be easiest to just run this code below:

1;
clear all
fflush(stdin);
filenameT='C:\Users\fsonnichsen\Dropbox\CHANOS\LEDs\data\2018_02_14a\T.txt';
[dtmeT, T] = textread (filenameT, "%s %f");

%%%%%%%%%%  TEMPERATURE PLOT %%%%%%%%%%%%%%%
  timeFormat='HH:MM:SS';
  ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
  plot(ser_date,T ,'color','k'  );
%  plot(ser_date-datenum("00:00:00"),T ,'color','k' )
  datetick('x',timeFormat,'keepticks')
    xlen = length(dtmeT);
  axis([0 xlen 20 75])

return
==============DATA ================================
14:30:06    22.8
14:30:07    22.8
14:30:08    22.8
14:30:09    22.8
14:30:10    22.8
14:30:11    22.7
===============================================
On 2/14/2018 4:03 PM, Ian McCallion wrote:
Are you sure all the dates are valid and in a sensible range?

On 14 Feb 2018 7:01 pm, "Fritz Sonnichsen" <[hidden email]> wrote:
Octave 4.0.0
I am trying to plot a time series data. I found some examples and tried them but they don't seem to work. I have data as shown:
9:00:38      23.9
9:00:39      23.9
.....

My code looks like this:
[dtmeT, T] = textread (filenameT, "%s %f");  %read in the data
   timeFormat='HH:MM:SS';
  ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
  plot(ser_date,T ,'color','k'  );
  datetick('x',timeFormat,'keepticks')
  xlen = length(dtmeT)  ;
  axis([0 xlen 20 35])

I get a time labeled axis as expected, but I do not see the plot of T.  The data is valid-if I plot it without time formatting it works fine.

thanks
fritz



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Problem plotting time on X axis

Przemek Klosowski-7
In reply to this post by Fritz Sonnichsen
On 02/14/2018 03:08 PM, Fritz Sonnichsen wrote:

> On 2/14/2018 2:25 PM, Przemek Klosowski wrote:
>> On 02/14/2018 02:00 PM, Fritz Sonnichsen wrote:
>>> ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
>>>   plot(ser_date,T ,'color','k'  );
>>>   datetick('x',timeFormat,'keepticks')
>>>   xlen = length(dtmeT)  ;
>>>   axis([0 xlen 20 35])
>>
>> I think it's a manifestation of the magnitude bug in the default
>> toolkit (fltk?). The problem is that fltk can't plot intervals that
>> have a short span compared to the magnitude of the endpoints. Since
>> you don't seem to care about the actual date, resetting the beginning
>> to midnight works around that:
>>
>> plot(ser_date-datenum("00:00:00"),T ,'color','k' )
> I tried that and it did not work.  My "ser_date" is numbers like:
> 7.3706e+005

Right--you have to do the  whole thing of course, including setting the
datetick.

dtmeT = {"9:00:38" "9:00:39" "9:00:40" "9:00:41"}
T = [   23.900    23.900   22.900   21.100]
timeFormat='HH:MM:SS';
   ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
plot(ser_date-datenum("00:00:00"),T ,'color','k' )
datetick('x',timeFormat,'keepticks')

In general, it's  easier for everyone if you ask questions by providing
a complete, standalone example that can run in a fresh Octave session. I
just copied-and-pasted the above snippet and got an expected
graph---what exactly is happening in your case?


-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Problem plotting time on X axis

Ian McCallion
In reply to this post by Fritz Sonnichsen
Hi Fritz,

I think this is what you want:

  dtmeT = {"9:00:38" "9:00:39" "9:00:40" "9:00:41"}
  T = [   23.900    23.900   22.900   21.100]

  timeFormat='HH:MM:SS';
  ser_date=(rem(datenum(dtmeT,timeFormat),1));
  plot(ser_date,T ,'color','k'  );
  datetick('x',13,'keepticks');
  axis([-Inf Inf 20 75]);

Cheers... Ian

On 14 Feb 2018 9:37 pm, "Fritz Sonnichsen" <[hidden email]> wrote:
Thanks Ian.
The seem to be in proper sequence. I am not asking you to do my work but to see this it may be easiest to just run this code below:

1;
clear all
fflush(stdin);
filenameT='C:\Users\fsonnichsen\Dropbox\CHANOS\LEDs\data\2018_02_14a\T.txt';
[dtmeT, T] = textread (filenameT, "%s %f");

%%%%%%%%%%  TEMPERATURE PLOT %%%%%%%%%%%%%%%
  timeFormat='HH:MM:SS';
  ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
  plot(ser_date,T ,'color','k'  );
%  plot(ser_date-datenum("00:00:00"),T ,'color','k' )
  datetick('x',timeFormat,'keepticks')
    xlen = length(dtmeT);
  axis([0 xlen 20 75])

return
==============DATA ================================
14:30:06    22.8
14:30:07    22.8
14:30:08    22.8
14:30:09    22.8
14:30:10    22.8
14:30:11    22.7
===============================================
On 2/14/2018 4:03 PM, Ian McCallion wrote:
Are you sure all the dates are valid and in a sensible range?

On 14 Feb 2018 7:01 pm, "Fritz Sonnichsen" <[hidden email]> wrote:
Octave 4.0.0
I am trying to plot a time series data. I found some examples and tried them but they don't seem to work. I have data as shown:
9:00:38      23.9
9:00:39      23.9
.....

My code looks like this:
[dtmeT, T] = textread (filenameT, "%s %f");  %read in the data
   timeFormat='HH:MM:SS';
  ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
  plot(ser_date,T ,'color','k'  );
  datetick('x',timeFormat,'keepticks')
  xlen = length(dtmeT)  ;
  axis([0 xlen 20 35])

I get a time labeled axis as expected, but I do not see the plot of T.  The data is valid-if I plot it without time formatting it works fine.

thanks
fritz



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Problem plotting time on X axis

Fritz Sonnichsen
Thanks Ian! This solved the problem. I guess the main point was that I need to remove the whole number offset from the serial date.
Fritz

On 2/15/2018 8:46 AM, Ian McCallion wrote:
Hi Fritz,

I think this is what you want:

  dtmeT = {"9:00:38" "9:00:39" "9:00:40" "9:00:41"}
  T = [   23.900    23.900   22.900   21.100]

  timeFormat='HH:MM:SS';
  ser_date=(rem(datenum(dtmeT,timeFormat),1));
  plot(ser_date,T ,'color','k'  );
  datetick('x',13,'keepticks');
  axis([-Inf Inf 20 75]);

Cheers... Ian

On 14 Feb 2018 9:37 pm, "Fritz Sonnichsen" <[hidden email]> wrote:
Thanks Ian.
The seem to be in proper sequence. I am not asking you to do my work but to see this it may be easiest to just run this code below:

1;
clear all
fflush(stdin);
filenameT='C:\Users\fsonnichsen\Dropbox\CHANOS\LEDs\data\2018_02_14a\T.txt';
[dtmeT, T] = textread (filenameT, "%s %f");

%%%%%%%%%%  TEMPERATURE PLOT %%%%%%%%%%%%%%%
  timeFormat='HH:MM:SS';
  ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
  plot(ser_date,T ,'color','k'  );
%  plot(ser_date-datenum("00:00:00"),T ,'color','k' )
  datetick('x',timeFormat,'keepticks')
    xlen = length(dtmeT);
  axis([0 xlen 20 75])

return
==============DATA ================================
14:30:06    22.8
14:30:07    22.8
14:30:08    22.8
14:30:09    22.8
14:30:10    22.8
14:30:11    22.7
===============================================
On 2/14/2018 4:03 PM, Ian McCallion wrote:
Are you sure all the dates are valid and in a sensible range?

On 14 Feb 2018 7:01 pm, "Fritz Sonnichsen" <[hidden email]> wrote:
Octave 4.0.0
I am trying to plot a time series data. I found some examples and tried them but they don't seem to work. I have data as shown:
9:00:38      23.9
9:00:39      23.9
.....

My code looks like this:
[dtmeT, T] = textread (filenameT, "%s %f");  %read in the data
   timeFormat='HH:MM:SS';
  ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
  plot(ser_date,T ,'color','k'  );
  datetick('x',timeFormat,'keepticks')
  xlen = length(dtmeT)  ;
  axis([0 xlen 20 35])

I get a time labeled axis as expected, but I do not see the plot of T.  The data is valid-if I plot it without time formatting it works fine.

thanks
fritz



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------




-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Problem plotting time on X axis

Fritz Sonnichsen
In reply to this post by Przemek Klosowski-7
thanks for responding--See Ian's post--that fixed the problem-I was not
seeing any plot line despite the fact that the X labels looked appropriate.
Fritz

On 2/14/2018 5:32 PM, Przemek Klosowski wrote:

> On 02/14/2018 03:08 PM, Fritz Sonnichsen wrote:
>> On 2/14/2018 2:25 PM, Przemek Klosowski wrote:
>>> On 02/14/2018 02:00 PM, Fritz Sonnichsen wrote:
>>>> ser_date=datenum(dtmeT,timeFormat); %serial date is secs since
>>>> 1/1/0000
>>>>   plot(ser_date,T ,'color','k'  );
>>>>   datetick('x',timeFormat,'keepticks')
>>>>   xlen = length(dtmeT)  ;
>>>>   axis([0 xlen 20 35])
>>>
>>> I think it's a manifestation of the magnitude bug in the default
>>> toolkit (fltk?). The problem is that fltk can't plot intervals that
>>> have a short span compared to the magnitude of the endpoints. Since
>>> you don't seem to care about the actual date, resetting the
>>> beginning to midnight works around that:
>>>
>>> plot(ser_date-datenum("00:00:00"),T ,'color','k' )
>> I tried that and it did not work.  My "ser_date" is numbers like:
>> 7.3706e+005
>
> Right--you have to do the  whole thing of course, including setting
> the datetick.
>
> dtmeT = {"9:00:38" "9:00:39" "9:00:40" "9:00:41"}
> T = [   23.900    23.900   22.900   21.100]
> timeFormat='HH:MM:SS';
>   ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
> plot(ser_date-datenum("00:00:00"),T ,'color','k' )
> datetick('x',timeFormat,'keepticks')
>
> In general, it's  easier for everyone if you ask questions by
> providing a complete, standalone example that can run in a fresh
> Octave session. I just copied-and-pasted the above snippet and got an
> expected graph---what exactly is happening in your case?
>
>
> -----------------------------------------
> Join us March 12-15 at CERN near Geneva
> Switzerland for OctConf 2018.  More info:
> https://wiki.octave.org/OctConf_2018
> -----------------------------------------



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Problem plotting time on X axis

Przemek Klosowski-7
On 02/15/2018 09:34 AM, Fritz Sonnichsen wrote:
thanks for responding--See Ian's post--that fixed the problem-I was not seeing any plot line despite the fact that the X labels looked appropriate.
Right---Ian removed the large integer number by rem(), and I did the same thing by subtracting the midnight date. Numerically, in our simple example they amount to the same thing, except that if your data covered several days, rem() would collapse them onto each other, whereas subtracting the midnight would allow you to plot more than one day.
plot(ser_date-datenum("00:00:00"),T ,'color','k' )


-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Problem plotting time on X axis

Ian McCallion
Fritz,

Part of the problem was that in your original question the comment was
incorrect:
    ser_date=datenum(dtmeT,timeFormat); %serial date is secs since 1/1/0000
It should have been
    ser_date=datenum(dtmeT,timeFormat); %serial date is days since 1/1/0000

Good example of comments causing bugs!!

Ian

On 15 February 2018 at 17:32, Przemek Klosowski
<[hidden email]> wrote:

> On 02/15/2018 09:34 AM, Fritz Sonnichsen wrote:
>
> thanks for responding--See Ian's post--that fixed the problem-I was not
> seeing any plot line despite the fact that the X labels looked appropriate.
>
> Right---Ian removed the large integer number by rem(), and I did the same
> thing by subtracting the midnight date. Numerically, in our simple example
> they amount to the same thing, except that if your data covered several
> days, rem() would collapse them onto each other, whereas subtracting the
> midnight would allow you to plot more than one day.
>
> plot(ser_date-datenum("00:00:00"),T ,'color','k' )
>
>
>
> -----------------------------------------
> Join us March 12-15 at CERN near Geneva
> Switzerland for OctConf 2018.  More info:
> https://wiki.octave.org/OctConf_2018
> -----------------------------------------
>


-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------