Change xaxis labels

Hi, I have a plot and the xaxis shows number of seconds after a start point. I would like to convert them to days anyone know how to do this. I have looked at the documentation but cant find what I need.

Couldn’t you divide your data points by the conversion (86400) before plotting? E.g., 432,000 seconds then becomes 5 days.

···

On Mon, Feb 6, 2012 at 9:23 AM, David Craig <dcdavemail@…287…> wrote:

Hi, I have a plot and the xaxis shows number of seconds after a start

point. I would like to convert them to days anyone know how to do this.

I have looked at the documentation but cant find what I need.

C M, on 2012-02-06 09:33, wrote:

> Hi, I have a plot and the xaxis shows number of seconds after a start
> point. I would like to convert them to days anyone know how to do this.
> I have looked at the documentation but cant find what I need.

Couldn't you divide your data points by the conversion (86400) before
plotting? E.g., 432,000 seconds then becomes 5 days.

Another way to do this is to change the Formatter which generates
what the labels of each tick out to be to do this computation.

Take a look at this example:
http://matplotlib.sourceforge.net/examples/api/date_index_formatter.html

Just define something like:

def your_function(x,pos=None):
    return "%d days" % (x/86400)

ax.xaxis.set_major_formatter(ticker.FuncFormatter(your_function))

best,

···

On Mon, Feb 6, 2012 at 9:23 AM, David Craig <dcdavemail@...287...> wrote:

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7