pycon_2015_bokeh_talk icon indicating copy to clipboard operation
pycon_2015_bokeh_talk copied to clipboard

Support Bokeh 0.9

Open birdsarah opened this issue 10 years ago • 3 comments

This repo only works with bokeh v0.8.2, a number of changes in 0.9 prevent an upgrade:

  • https://groups.google.com/a/continuum.io/d/msgid/bokeh/0680a002-7574-4abb-984a-242c76f1f3bf%40continuum.io?utm_medium=email&utm_source=footer
  • https://groups.google.com/a/continuum.io/d/msgid/bokeh/0cceb4ba-bd40-4e4f-bf26-214865c19566%40continuum.io?utm_medium=email&utm_source=footer

birdsarah avatar May 21 '15 22:05 birdsarah

Hi, I encountered an issue and I'm not sure whether it's the result of changes in newer bokeh versions (only those between 0.8.2 and 0.9 are mentioned above) or a bug.

Setup

My python and bokeh versions are

Python version      :  3.5.1+ (default, Mar 30 2016, 22:46:26)
Bokeh version       :  0.11.1

and I installed following packages:

> pip freeze
backports.shutil-get-terminal-size==1.0.0
bokeh==0.11.1
decorator==4.0.9
ipython==4.2.0
ipython-genutils==0.1.0
Jinja2==2.8
MarkupSafe==0.23
numpy==1.11.0
pandas==0.18.1
pexpect==4.1.0
pickleshare==0.7.2
pkg-resources==0.0.0
ptyprocess==0.5.1
python-dateutil==2.5.3
pytz==2016.4
PyYAML==3.11
requests==2.10.0
simplegeneric==0.8.1
six==1.10.0
tornado==4.3
traitlets==4.2.1

Issue

I used parts of the code you provided in washmap/washmap/water_map.py and tried to generate a colorbar:

from bokeh.plotting import show, output_file
from bokeh.models import Plot, Range1d, Text, Rect

COLORS = ["#F1EEF6", "#D4B9DA", "#C994C7", "#DF65B0", "#DD1C77", "#980043"]
PLOT_SIZE = dict(
    # plot_width=250,
    # plot_height=50
)

xdr = Range1d(0, 250)
ydr = Range1d(0, 50)

plot = Plot(
    x_range=xdr,
    y_range=ydr,
    title="",
    min_border=0,
    toolbar_location=None,
    **PLOT_SIZE
)

for index, color in enumerate(COLORS):
    width = 30
    rect = Rect(
        x=((width * index) + 40), y=40,
        width=width, height=10,
        fill_color=color, line_color='white'
    )
    plot.add_glyph(rect)

zero = Text(x=30, y=15, text=['0 %'])
hundred = Text(x=190, y=15, text=['100 %'])
plot.add_glyph(zero)
plot.add_glyph(hundred)


output_file("color_bar.html", title="color bar example")

show(plot)

The given code returns following result, which looks good so far. bokeh_test

But as soon as I change the Plot-size options (line 5-8 in the example code)

PLOT_SIZE = dict(
    plot_width=250,
    plot_height=50
)

only a white page is returned and the JS console says: Error: unsatisfiable constraint.

Am I using the Plot model in a wrong way or is it actually a bug which I should file in the main bokeh repo? Many thanks in advance!

libeanim avatar May 24 '16 15:05 libeanim

I wouldn't expect much of this code to work with the latest version of Bokeh. I've been meaning to do a remake for Pycon (coming up next week). I would start with the bokeh docs and examples. http://bokeh.pydata.org/en/latest/ - http://bokeh.pydata.org/en/latest/docs/gallery.html

birdsarah avatar May 24 '16 16:05 birdsarah

OK, thanks for your quick response! I will look through the official docs. Would be happy about a remake. :+1:

libeanim avatar May 24 '16 21:05 libeanim