can Label() or figure.text() work with a datetime x-axis?

Greetings,

I have been trying to figure out how to insert a label or text in my timeseries plot. I keep getting an error.
Either.

  1. ValueError: expected a value of type Real, got 2013-07-03 00:00:00 of type Timestamp (using Label())

  2. ValueError: expected an element of either String, Dict(String, Either(String, Instance(Transform), Instance(ColorMapper), Float)) or Float, got Timestamp(‘2013-07-03 00:00:00’, offset=‘B’)

I am not sure what I am doing wrong. I would be grateful for any help. I tried using DatetimeIndex and PeriodIndex

An example below of the errors are below using Bokeh 0.12.4 and python 3.5.2:

import numpy as np

import pandas as pd

from bokeh.plotting import figure, output_file, show

from bokeh.models import Label

x = pd.date_range(‘2010-01-01’,‘2017-01-01’, freq= ‘B’)

y = x.to_period(‘B’)

data = np.random.randn(len(x))*100

output_file(‘label_test.html’)

timeseries = pd.Series(data, index = x)

timeseries2 =pd.Series(data, index = y)

plot1 = figure(x_axis_type = ‘datetime’)

plot1.line(x, data)

plot1.text(x = x[len(x)//2], y = np.max(data), text = ‘success’)

point1 = Label(x= x[len(x)//2], y = np.max(data), text= ‘Success’, render_mode = ‘canvas’)

plot1.add_layout(point1)

show(plot1)

This was recently noticed as a missing feature:

  Numberspec coordinates should accept datetimes · Issue #5831 · bokeh/bokeh · GitHub

In the mean time, a workaround is to explicitly convert the datetime values into floating point "milliseconds since epoch" which is the actual serialization format that is used under the hood.

Thanks,

Bryan

···

On Feb 10, 2017, at 12:56, javbo <[email protected]> wrote:

Greetings,

I have been trying to figure out how to insert a label or text in my timeseries plot. I keep getting an error.
Either.
1. ValueError: expected a value of type Real, got 2013-07-03 00:00:00 of type Timestamp (using Label())
2. ValueError: expected an element of either String, Dict(String, Either(String, Instance(Transform), Instance(ColorMapper), Float)) or Float, got Timestamp('2013-07-03 00:00:00', offset='B')

I am not sure what I am doing wrong. I would be grateful for any help. I tried using DatetimeIndex and PeriodIndex

An example below of the errors are below using Bokeh 0.12.4 and python 3.5.2:

import numpy as np
import pandas as pd
from bokeh.plotting import figure, output_file, show
from bokeh.models import Label

x = pd.date_range('2010-01-01','2017-01-01', freq= 'B')
y = x.to_period('B')
data = np.random.randn(len(x))*100
output_file('label_test.html')
timeseries = pd.Series(data, index = x)
timeseries2 =pd.Series(data, index = y)

plot1 = figure(x_axis_type = 'datetime')
plot1.line(x, data)
plot1.text(x = x[len(x)//2], y = np.max(data), text = 'success')
# point1 = Label(x= x[len(x)//2], y = np.max(data), text= 'Success', render_mode = 'canvas')
# plot1.add_layout(point1)

show(plot1)

--
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/1a108c14-4656-42d7-a387-98cf533ce2b3%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi Bryan,

As always, thank you very much. I am hoping that datetime will be supported in a future release.

I would appreciate if you can have a look at an issue I posted on Jan. 11 when you have the time. I believe there is an issue with the Legends outside the plot area. When decreasing the size of the plot, the plot container (plot + legend) reduces in size, but the plot does not keep its default proportions and the legend container maintains the same size (so when resizing, the actual plot looks disproportionate and becomes almost invisible) I think if the legend is in a different container (div element) this would not cause problems.

Link to my previous post.

https://groups.google.com/a/continuum.io/forum/#!mydiscussions/bokeh/g-4dZ83Xnsc

Hi,

Apologies but I've lost two weeks to being sick, then a conference. Now my laptop has died and I am struggling to get a fully working dev environment set up on a completely new laptop. I am about 400 emails and messages underwater, I need to get a new dev build out, and help provide guidance for the tasks already prioritized for 0.12.5 that are behind. I wish I could promise to look at that soon personally, but realistically, that will probably not be possible.

If it seems like a bug (sounds quite possible from the description) then the best thing to do is to submit a GH bug report issue with code to reproduce, so that it does not get lost in the shuffle, and can be properly prioritized in the context of a larger group of people.

Thanks,

Bryan

···

On Feb 13, 2017, at 12:53, javbo <[email protected]> wrote:

Hi Bryan,

As always, thank you very much. I am hoping that datetime will be supported in a future release.

I would appreciate if you can have a look at an issue I posted on Jan. 11 when you have the time. I believe there is an issue with the Legends outside the plot area. When decreasing the size of the plot, the plot container (plot + legend) reduces in size, but the plot does not keep its default proportions and the legend container maintains the same size (so when resizing, the actual plot looks disproportionate and becomes almost invisible) I think if the legend is in a different container (div element) this would not cause problems.

Link to my previous post.

Redirecting to Google Groups

--
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/c6159b17-77ee-4b06-bd1b-ceaab2fda522%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Thanks Bryan. Will do.

···

On Monday, February 13, 2017 at 5:57:19 PM UTC-5, Bryan Van de ven wrote:

Hi,

Apologies but I’ve lost two weeks to being sick, then a conference. Now my laptop has died and I am struggling to get a fully working dev environment set up on a completely new laptop. I am about 400 emails and messages underwater, I need to get a new dev build out, and help provide guidance for the tasks already prioritized for 0.12.5 that are behind. I wish I could promise to look at that soon personally, but realistically, that will probably not be possible.

If it seems like a bug (sounds quite possible from the description) then the best thing to do is to submit a GH bug report issue with code to reproduce, so that it does not get lost in the shuffle, and can be properly prioritized in the context of a larger group of people.

Thanks,

Bryan

On Feb 13, 2017, at 12:53, javbo [email protected] wrote:

Hi Bryan,

As always, thank you very much. I am hoping that datetime will be supported in a future release.

I would appreciate if you can have a look at an issue I posted on Jan. 11 when you have the time. I believe there is an issue with the Legends outside the plot area. When decreasing the size of the plot, the plot container (plot + legend) reduces in size, but the plot does not keep its default proportions and the legend container maintains the same size (so when resizing, the actual plot looks disproportionate and becomes almost invisible) I think if the legend is in a different container (div element) this would not cause problems.

Link to my previous post.

https://groups.google.com/a/continuum.io/forum/#!mydiscussions/bokeh/g-4dZ83Xnsc


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/c6159b17-77ee-4b06-bd1b-ceaab2fda522%40continuum.io.

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