☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

segment, mixing ints and dates

Community Support
Jared_Thompson
Jared_Thompson

I was playing with segments, and everything was find as long as I used lists of integers, however I had a need come up where I needed/wanted to put time on the x axis and integers on the y axis. (It was to show durations(x axis in time) of behavior and the frequency/popularity(y-axis) of those patterns).

I was trying to do this with some dataframes in pandas and was not getting what I expected.

When I simplified the problem to the below I did not get an x-axis that I was expecting.

import bokeh.plotting as bp

import datetime

bp.output_file(“categorical.html”, title=“categorical.py example”)

bp.segment([datetime.date(2014,1,1)], [3], [datetime.date(2014,1,7)], [3],

line_width=20, line_color=“green”, title=“Dot Plot”)

bp.figure()

bp.show()

my x axis I was expecting to be some dates or some sort of readable range, however the tick marks are things like “1.3886e+12” “1.3887e+12”, is that expected?

⌁   Link to post
Jared_Thompson
Jared_Thompson

I will note, in the examples files I see lots of references to:

figure(x_axis_type = "datetime",
such as in:
[http://bokeh.pydata.org/docs/gallery/stocks.html](http://bokeh.pydata.org/docs/gallery/stocks.html)

and I can run that example and it works.

I did go back into my plot and add in:
bp.figure(x_axis_type="datetime")

although that did not change anything - is it because I am using a segment - or have I erred in some other way?

I can see the x_asis_type here:
[https://github.com/ContinuumIO/bokeh/blob/5b8c12200c1170c1c6a76d8afb22cddf1a7efb1d/bokeh/plotting_helpers.py](https://github.com/ContinuumIO/bokeh/blob/5b8c12200c1170c1c6a76d8afb22cddf1a7efb1d/bokeh/plotting_helpers.py)





···

On Thu, Jun 19, 2014 at 9:19 PM, jared afonit@gmail.com wrote:

I was playing with segments, and everything was find as long as I used lists of integers, however I had a need come up where I needed/wanted to put time on the x axis and integers on the y axis. (It was to show durations(x axis in time) of behavior and the frequency/popularity(y-axis) of those patterns).

I was trying to do this with some dataframes in pandas and was not getting what I expected.

When I simplified the problem to the below I did not get an x-axis that I was expecting.

import bokeh.plotting as bp

import datetime

bp.output_file(“categorical.html”, title=“categorical.py example”)

bp.segment([datetime.date(2014,1,1)], [3], [datetime.date(2014,1,7)], [3],

line_width=20, line_color=“green”, title=“Dot Plot”)

bp.figure()

bp.show()

my x axis I was expecting to be some dates or some sort of readable range, however the tick marks are things like “1.3886e+12” “1.3887e+12”, is that expected?

⌁   Link to post
kungfuturtle
kungfuturtle

Hi Jared,

Unfortunately you encountered that error through our fault. Our documentation will require significant upgrading as we prepare for SciPy, so hopefully you won’t encounter a similar situation in the future, but at least for now I can help fix your problem quite simply.

The call to figure() should be placed before those to any renderers. Calling figure() means to create a new figure, i.e. a new plot, upon which to add subsequent renderers. Therefore your code should work if written as shown here: http://nbviewer.ipython.org/github/kdodia/examples/blob/master/Datetime%20Plotting.ipynb

Karan

···

On Thursday, June 19, 2014 9:09:41 PM UTC-5, Jared Thompson wrote:

I will note, in the examples files I see lots of references to:

figure(x_axis_type = "datetime",
such as in:
[http://bokeh.pydata.org/docs/gallery/stocks.html](http://bokeh.pydata.org/docs/gallery/stocks.html)


and I can run that example and it works.


I did go back into my plot and add in:
bp.figure(x_axis_type="datetime")

although that did not change anything - is it because I am using a segment - or have I erred in some other way?


I can see the x_asis_type here:
[https://github.com/ContinuumIO/bokeh/blob/5b8c12200c1170c1c6a76d8afb22cddf1a7efb1d/bokeh/plotting_helpers.py](https://github.com/ContinuumIO/bokeh/blob/5b8c12200c1170c1c6a76d8afb22cddf1a7efb1d/bokeh/plotting_helpers.py)










On Thu, Jun 19, 2014 at 9:19 PM, jared afo...@gmail.com wrote:

I was playing with segments, and everything was find as long as I used lists of integers, however I had a need come up where I needed/wanted to put time on the x axis and integers on the y axis. (It was to show durations(x axis in time) of behavior and the frequency/popularity(y-axis) of those patterns).

I was trying to do this with some dataframes in pandas and was not getting what I expected.

When I simplified the problem to the below I did not get an x-axis that I was expecting.

import bokeh.plotting as bp

import datetime

bp.output_file(“categorical.html”, title=“categorical.py example”)

bp.segment([datetime.date(2014,1,1)], [3], [datetime.date(2014,1,7)], [3],

line_width=20, line_color=“green”, title=“Dot Plot”)

bp.figure()

bp.show()

my x axis I was expecting to be some dates or some sort of readable range, however the tick marks are things like “1.3886e+12” “1.3887e+12”, is that expected?

⌁   Link to post
Jared_Thompson
Jared_Thompson

ok, I see my mistake, the x_axis_type goes inside the bp.secgemnt().
I will file the bug report you eluded to on the json.

Thanks for your help

···

On Thu, Jun 19, 2014 at 10:54 PM, kungfuturtle@gmail.com wrote:

Hi Jared,

Unfortunately you encountered that error through our fault. Our documentation will require significant upgrading as we prepare for SciPy, so hopefully you won’t encounter a similar situation in the future, but at least for now I can help fix your problem quite simply.

The call to figure() should be placed before those to any renderers. Calling figure() means to create a new figure, i.e. a new plot, upon which to add subsequent renderers. Therefore your code should work if written as shown here: http://nbviewer.ipython.org/github/kdodia/examples/blob/master/Datetime%20Plotting.ipynb

Karan

On Thursday, June 19, 2014 9:09:41 PM UTC-5, Jared Thompson wrote:

I will note, in the examples files I see lots of references to:

figure(x_axis_type = "datetime",
such as in:
[http://bokeh.pydata.org/docs/gallery/stocks.html](http://bokeh.pydata.org/docs/gallery/stocks.html)



and I can run that example and it works.


I did go back into my plot and add in:
bp.figure(x_axis_type="datetime")

although that did not change anything - is it because I am using a segment - or have I erred in some other way?


I can see the x_asis_type here:
[https://github.com/ContinuumIO/bokeh/blob/5b8c12200c1170c1c6a76d8afb22cddf1a7efb1d/bokeh/plotting_helpers.py](https://github.com/ContinuumIO/bokeh/blob/5b8c12200c1170c1c6a76d8afb22cddf1a7efb1d/bokeh/plotting_helpers.py)











On Thu, Jun 19, 2014 at 9:19 PM, jared afo...@gmail.com wrote:

I was playing with segments, and everything was find as long as I used lists of integers, however I had a need come up where I needed/wanted to put time on the x axis and integers on the y axis. (It was to show durations(x axis in time) of behavior and the frequency/popularity(y-axis) of those patterns).

I was trying to do this with some dataframes in pandas and was not getting what I expected.

When I simplified the problem to the below I did not get an x-axis that I was expecting.

import bokeh.plotting as bp

import datetime

bp.output_file(“categorical.html”, title=“categorical.py example”)

bp.segment([datetime.date(2014,1,1)], [3], [datetime.date(2014,1,7)], [3],

line_width=20, line_color=“green”, title=“Dot Plot”)

bp.figure()

bp.show()

my x axis I was expecting to be some dates or some sort of readable range, however the tick marks are things like “1.3886e+12” “1.3887e+12”, is that expected?

–

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 bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0b4c9d10-102c-4c6f-aca3-fca9627fd040%40continuum.io.

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

⌁   Link to post

End of archived discussion · Replies are disabled