controlling format of axis labels for datetime axis

Hi,

I’ve been plotting data where the x values are datetime objects. Using the x_axis_type = ‘datetime’ argument to figure, that axis is labeled correctly but with a very short format: hh:mm (where hh is the hour and mm is the minutes). I’d like to have a longer string used for the date which would include the month and day, even though it is redundant (i.e. every point will have the same month and day in most cases). How do I do that? I was looking at the methods and attributes of the axis and nothing jumped out at me.

Thanks,

Jon

Hi,

When you specify "datetime" then your axis gets configured with a DatetimeTickFormatter, which can be accessed by, e.g.

  plot.xaxis.formatter

The different scales for DatetimeTickFormatter can be configured at a fine level:

  http://bokeh.pydata.org/en/latest/docs/reference/models/formatters.html#bokeh.models.formatters.DatetimeTickFormatter

However, I notice that there is nothing about this in the users guide. It would be good to add something about this there as well. I'd encourage you to open a GitHub issue for this (and also submit a PR if you are able).

Thanks,

Bryan

···

On Apr 10, 2017, at 13:35, Jonathan Slavin <[email protected]> wrote:

Hi,

I've been plotting data where the x values are datetime objects. Using the x_axis_type = 'datetime' argument to figure, that axis is labeled correctly but with a very short format: hh:mm (where hh is the hour and mm is the minutes). I'd like to have a longer string used for the date which would include the month and day, even though it is redundant (i.e. every point will have the same month and day in most cases). How do I do that? I was looking at the methods and attributes of the axis and nothing jumped out at me.

Thanks,
Jon

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/bb7be028-787c-43de-8d03-a0ab4d02316c%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

Thanks for your response. I was looking at that page and having a hard time figuring out what was going wrong with my attempts to set the values of some attributes. I discovered that I had an older version of bokeh installed and the class definition of the DatetimeTickFormatter has changed substantially. After updating, I can now set the attributes (.e.g hourmin) as I wanted.

This has led me to another issue, however. In maplotlib the datetime tick labels that are too long can be made to angle diagonally so that they don’t overlap. Can that be done with bokeh?

Regards,

Jon

···

On Tue, Apr 11, 2017 at 12:43 PM, Bryan Van de ven [email protected] wrote:

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

When you specify “datetime” then your axis gets configured with a DatetimeTickFormatter, which can be accessed by, e.g.

    plot.xaxis.formatter

The different scales for DatetimeTickFormatter can be configured at a fine level:

    [http://bokeh.pydata.org/en/latest/docs/reference/models/formatters.html#bokeh.models.formatters.DatetimeTickFormatter](http://bokeh.pydata.org/en/latest/docs/reference/models/formatters.html#bokeh.models.formatters.DatetimeTickFormatter)

However, I notice that there is nothing about this in the users guide. It would be good to add something about this there as well. I’d encourage you to open a GitHub issue for this (and also submit a PR if you are able).

Thanks,

Bryan

On Apr 10, 2017, at 13:35, Jonathan Slavin [email protected] wrote:

Hi,

I’ve been plotting data where the x values are datetime objects. Using the x_axis_type = ‘datetime’ argument to figure, that axis is labeled correctly but with a very short format: hh:mm (where hh is the hour and mm is the minutes). I’d like to have a longer string used for the date which would include the month and day, even though it is redundant (i.e. every point will have the same month and day in most cases). How do I do that? I was looking at the methods and attributes of the axis and nothing jumped out at me.

Thanks,

Jon

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/bb7be028-787c-43de-8d03-a0ab4d02316c%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/ym0BQDeiccQ/unsubscribe.

To unsubscribe from this group and all its topics, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3B34D270-E4E4-4EDF-B43C-C7606F9900FE%40continuum.io.


Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA


Hi Bryan,

Thanks for your response. I was looking at that page and having a hard time figuring out what was going wrong with my attempts to set the values of some attributes. I discovered that I had an older version of bokeh installed and the class definition of the DatetimeTickFormatter has changed substantially. After updating, I can now set the attributes (.e.g hourmin) as I wanted.

Yes it's been changed for quite a white now. The old version was too easy to misconfigure in ways that caused hard to diagnose errors.

This has led me to another issue, however. In maplotlib the datetime tick labels that are too long can be made to angle diagonally so that they don't overlap. Can that be done with bokeh?

That's a property of the axis:

  http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#tick-label-orientation

Thanks,

Bryan

···

On Apr 11, 2017, at 13:25, Slavin, Jonathan <[email protected]> wrote:

Regards,
Jon

On Tue, Apr 11, 2017 at 12:43 PM, Bryan Van de ven <[email protected]> wrote:
Hi,

When you specify "datetime" then your axis gets configured with a DatetimeTickFormatter, which can be accessed by, e.g.

        plot.xaxis.formatter

The different scales for DatetimeTickFormatter can be configured at a fine level:

        http://bokeh.pydata.org/en/latest/docs/reference/models/formatters.html#bokeh.models.formatters.DatetimeTickFormatter

However, I notice that there is nothing about this in the users guide. It would be good to add something about this there as well. I'd encourage you to open a GitHub issue for this (and also submit a PR if you are able).

Thanks,

Bryan

> On Apr 10, 2017, at 13:35, Jonathan Slavin <[email protected]> wrote:
>
> Hi,
>
> I've been plotting data where the x values are datetime objects. Using the x_axis_type = 'datetime' argument to figure, that axis is labeled correctly but with a very short format: hh:mm (where hh is the hour and mm is the minutes). I'd like to have a longer string used for the date which would include the month and day, even though it is redundant (i.e. every point will have the same month and day in most cases). How do I do that? I was looking at the methods and attributes of the axis and nothing jumped out at me.
>
> Thanks,
> Jon
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/bb7be028-787c-43de-8d03-a0ab4d02316c%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/ym0BQDeiccQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3B34D270-E4E4-4EDF-B43C-C7606F9900FE%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CACcRS%3De%3D_DO9QU-LxGbCjXiwjKDBBwfYZ2B3JeV1H%3DfTMtisFg%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

​Thanks for the pointer to how to change label orientation. I should be all
set now.​

···

On Tue, Apr 11, 2017 at 3:27 PM, Bryan Van de ven <[email protected]> wrote:

> On Apr 11, 2017, at 13:25, Slavin, Jonathan <[email protected]> > wrote:
>
> Hi Bryan,
>
> Thanks for your response. I was looking at that page and having a hard
time figuring out what was going wrong with my attempts to set the values
of some attributes. I discovered that I had an older version of bokeh
installed and the class definition of the DatetimeTickFormatter has changed
substantially. After updating, I can now set the attributes (.e.g hourmin)
as I wanted.

Yes it's been changed for quite a white now. The old version was too easy
to misconfigure in ways that caused hard to diagnose errors.

> This has led me to another issue, however. In maplotlib the datetime
tick labels that are too long can be made to angle diagonally so that they
don't overlap. Can that be done with bokeh?

That's a property of the axis:

        http://bokeh.pydata.org/en/latest/docs/user_guide/
styling.html#tick-label-orientation

Thanks,

Bryan

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________