Formatter dates

Hello!

I have now been tampering with a custom formatter and the more i think about it the more i feel there must be a more easy soulution. I have a set of values that are plotted over time (i use date2num, to get the conversion from date to num), i also have a list with dates that corresponds to these values;
[‘2010-11-05 10:27:45.605000’, ‘2010-11-05 10:27:50.576000’, ‘2010-11-05 10:27:55.913000’], this to not have to do a conversion back, i imagine its the most effective way to do it.

Now to the question;

The only two values in the datelist that is vital is the first and the last, in between i really just want to have values that corresponds lineary. Thats brings me to resoulution, if the values are far far in between, say weeks or even moth the time (h:s:ms) isnt so important and vice versa.

Is there any formatter that do this sort of things? eg. takes in two values(dates) and format it by itself.

// Tim

Take a look at this example

http://matplotlib.sourceforge.net/examples/api/date_index_formatter.html

It's trying to solve a different but related problem: in financial
time series you only have data on Monday - Friday, and you don't want
to plot the gaps on weekends. So you plot the data linearly with an
index, and use a custom locator and formatter to set and format the
ticks.

JDH

···

On Wed, Nov 17, 2010 at 2:29 AM, Tim Åberg <qwigz@...32...> wrote:

Hello!

I have now been tampering with a custom formatter and the more i think about
it the more i feel there must be a more easy soulution. I have a set of
values that are plotted over time (i use date2num, to get the conversion
from date to num), i also have a list with dates that corresponds to these
values;
['2010-11-05 10:27:45.605000', '2010-11-05 10:27:50.576000', '2010-11-05
10:27:55.913000'], this to not have to do a conversion back, i imagine its
the most effective way to do it.

Now to the question;

The only two values in the datelist that is vital is the first and the last,
in between i really just want to have values that corresponds lineary. Thats
brings me to resoulution, if the values are far far in between, say weeks or
even moth the time (h:s:ms) isnt so important and vice versa.

Is there any formatter that do this sort of things? eg. takes in two
values(dates) and format it by itself.

Thanks for the reply!
I have been looking into it now and thinks i have get the hang of how it works rougly. Do you know any way to know the max-value of X straight away?
I have a list of dates that with listlength Y, the X spans from 0 - something. So if i could figure out what “something” is i could get the ratio and then plot the dates by indexing the ratio times X eg. (Xmax / listlength) * X.

// Tim

···

From: jdh2358@…287…
Date: Wed, 17 Nov 2010 05:55:04 -0600
Subject: Re: [Matplotlib-users] Formatter dates
To: qwigz@…32…
CC: matplotlib-users@lists.sourceforge.net

On Wed, Nov 17, 2010 at 2:29 AM, Tim Åberg <qwigz@…32…> wrote:

Hello!

I have now been tampering with a custom formatter and the more i think about
it the more i feel there must be a more easy soulution. I have a set of
values that are plotted over time (i use date2num, to get the conversion
from date to num), i also have a list with dates that corresponds to these
values;
[‘2010-11-05 10:27:45.605000’, ‘2010-11-05 10:27:50.576000’, ‘2010-11-05
10:27:55.913000’], this to not have to do a conversion back, i imagine its
the most effective way to do it.

Now to the question;

The only two values in the datelist that is vital is the first and the last,
in between i really just want to have values that corresponds lineary. Thats
brings me to resoulution, if the values are far far in between, say weeks or
even moth the time (h:s:ms) isnt so important and vice versa.

Is there any formatter that do this sort of things? eg. takes in two
values(dates) and format it by itself.

Take a look at this example

http://matplotlib.sourceforge.net/examples/api/date_index_formatter.html

It’s trying to solve a different but related problem: in financial
time series you only have data on Monday - Friday, and you don’t want
to plot the gaps on weekends. So you plot the data linearly with an
index, and use a custom locator and formatter to set and format the
ticks.

JDH

Solved it, was thinking backwards again.

···

From: qwigz@…32…
To: matplotlib-users@lists.sourceforge.net
Date: Mon, 22 Nov 2010 09:00:38 +0000
Subject: Re: [Matplotlib-users] Formatter dates

Thanks for the reply!
I have been looking into it now and thinks i have get the hang of how it works rougly. Do you know any way to know the max-value of X straight away?
I have a list of dates that with listlength Y, the X spans from 0 - something. So if i could figure out what “something” is i could get the ratio and then plot the dates by indexing the ratio times X eg. (Xmax / listlength) * X.

// Tim

From: jdh2358@…287…
Date: Wed, 17 Nov 2010 05:55:04 -0600
Subject: Re: [Matplotlib-users] Formatter dates
To: qwigz@…32…
CC: matplotlib-users@lists.sourceforge.net

On Wed, Nov 17, 2010 at 2:29 AM, Tim Åberg <qwigz@…32…> wrote:

Hello!

I have now been tampering with a custom formatter and the more i think about
it the more i feel there must be a more easy soulution. I have a set of
values that are plotted over time (i use date2num, to get the conversion
from date to num), i also have a list with dates that corresponds to these
values;
[‘2010-11-05 10:27:45.605000’, ‘2010-11-05 10:27:50.576000’, ‘2010-11-05
10:27:55.913000’], this to not have to do a conversion back, i imagine its
the most effective way to do it.

Now to the question;

The only two values in the datelist that is vital is the first and the last,
in between i really just want to have values that corresponds lineary. Thats
brings me to resoulution, if the values are far far in between, say weeks or
even moth the time (h:s:ms) isnt so important and vice versa.

Is there any formatter that do this sort of things? eg. takes in two
values(dates) and format it by itself.

Take a look at this example

http://matplotlib.sourceforge.net/examples/api/date_index_formatter.html

It’s trying to solve a different but related problem: in financial
time series you only have data on Monday - Friday, and you don’t want
to plot the gaps on weekends. So you plot the data linearly with an
index, and use a custom locator and formatter to set and format the
ticks.

JDH


Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thanks for the reply!

Do you know what makes X climb? And can you control its on some way?

// Tim

···

From: jdh2358@…1896…
Date: Wed, 17 Nov 2010 05:55:04 -0600
Subject: Re: [Matplotlib-users] Formatter dates
To: qwigz@…32…
CC: matplotlib-users@lists.sourceforge.net

On Wed, Nov 17, 2010 at 2:29 AM, Tim Åberg <qwigz@…32…> wrote:

Hello!

I have now been tampering with a custom formatter and the more i think about
it the more i feel there must be a more easy soulution. I have a set of
values that are plotted over time (i use date2num, to get the conversion
from date to num), i also have a list with dates that corresponds to these
values;
[‘2010-11-05 10:27:45.605000’, ‘2010-11-05 10:27:50.576000’, ‘2010-11-05
10:27:55.913000’], this to not have to do a conversion back, i imagine its
the most effective way to do it.

Now to the question;

The only two values in the datelist that is vital is the first and the last,
in between i really just want to have values that corresponds lineary. Thats
brings me to resoulution, if the values are far far in between, say weeks or
even moth the time (h:s:ms) isnt so important and vice versa.

Is there any formatter that do this sort of things? eg. takes in two
values(dates) and format it by itself.

Take a look at this example

http://matplotlib.sourceforge.net/examples/api/date_index_formatter.html

It’s trying to solve a different but related problem: in financial
time series you only have data on Monday - Friday, and you don’t want
to plot the gaps on weekends. So you plot the data linearly with an
index, and use a custom locator and formatter to set and format the
ticks.

JDH