opened 07:19AM - 01 Feb 17 UTC
closed 12:50PM - 13 May 17 UTC
type: feature
reso: completed
The following example should ideally make a simple plot and place a label using …data space coordinates:
```
from bokeh.plotting import show, output_file, figure
from bokeh.models import Label
from datetime import datetime
f = figure(x_axis_type="datetime")
f.line(x=[datetime(2015, 1, 1), datetime(2016, 1, 1)], y=[1,2])
label = Label(x=datetime(2015, 1, 1), y=2, text='Some label')
f.add_layout(label)
output_file('test.html')
show(f)
>>> ValueError: expected a value of type Real, got 2015-01-01 00:00:00 of type datetime
```
This seems to fail because Label coordinates do not accept datetime even tough it seems natural. The workaround is to convert the datetime coordinates to milliseconds since epoch, and try again:
```
from bokeh.plotting import show, output_file, figure
from bokeh.models import Label
from datetime import datetime
f = figure(x_axis_type="datetime")
f.line(x=[datetime(2015, 1, 1), datetime(2016, 1, 1)], y=[1,2])
x_label = datetime(2015, 1, 1).timestamp() * 1000
label = Label(x=x_label, y=2, text='Some label')
f.add_layout(label)
output_file('test.html')
show(f)
```
## Desired feature:
The suggestion is to have bokeh perform this conversion automatically when asked to use a datetime object as a coordinate, as this would be the most intuitive interaction when coordinates are specified in data space units.
```
Python version : 3.4.5 |Continuum Analytics, Inc.|(default, Jul 5 2016, 14:53:06) [MSC v.1600 64bit (AMD64)]
IPython version : (not installed)
Bokeh version : 0.12.4
node.js version : v0.12.2
```