Skip to content
This repository has been archived by the owner on Mar 17, 2020. It is now read-only.

Support Bokeh 0.9 #2

Open
birdsarah opened this issue May 21, 2015 · 3 comments
Open

Support Bokeh 0.9 #2

birdsarah opened this issue May 21, 2015 · 3 comments

Comments

@birdsarah
Copy link
Owner

@libeanim
Copy link

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!

@birdsarah
Copy link
Owner Author

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

@libeanim
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants