Question

Making a histogram on my own, the sum of each bars is 1. So each bar is smaller than 1. Why don't they fit into the plot window? How can I achieve this?

yaxis().bounds = [0,1]

This only sets the axis, but doesn't fit my plot. Is there no proper documentation for bokeh, I am getting mad on such simple problems.

from bokeh.plotting import *
from __future__ import division
output_notebook()
from bokeh.plotting import rect

balkenbreite = 5
mitten = [10,20,30,40]
werte = [10,15,10,5]
anteil = []
sumVal = sum(werte)
for i in range(len(werte)):
    anteil.append(0)
for i in range(len(anteil)):
    anteil[i] = werte[i]/sumVal
print anteil

figure()
hold(False)
rect([mitten[0]],[anteil[0]/2], width=balkenbreite, height=anteil[0], plot_width=400, color = "#ff1200", plot_height=400, tools="pan")
hold(True)
for i in range(len(mitten)):
    if i==0: continue
    rect([mitten[i]],[anteil[i]/2], width=balkenbreite, height=anteil[i], plot_width=400, color = "#ff1200", plot_height=400)
xaxis()[0].axis_label="Areas"
yaxis()[0].axis_label="Frequency"
yaxis()[0].bounds = [0,1]
show()

enter image description here

Was it helpful?

Solution

Note (4/8/2014): Bokeh is still under early but active development, so these kinds of questions are to be expected for the time being. We hope to answer them as quickly as possible as we continue to expand our documentation, but in the meantime you may find the tutorials to be helpful.

To the question at hand: currently plot ranges can be set with the Range1d object, which is assigned to the x_range or y_range keyword arguments. These can be set on the figure() instance.

These three lines should fix the issue:

from bokeh.objects import Range1d
yr = Range1d(start=0, end=1)
figure(y_range=yr)

Edit: here's a screenshot of what I imagine you want.

Screenshot

OTHER TIPS

the above answer from kpsfire answers the question, but I did want to make some additional remarks. The Bokeh docs site at http://docs.bokeh.org currently has many full code examples in a live gallery, an extensive API reference for both the python and javascript, user's and developer's guides, and a fairly substantial tutorial that has been well-received at a few different conferences. I think we at least have a decent start. :)

That said! There is always room for improvement and additions, and the best way to make sure the docs get better is to listen to feedback from users letting us know the areas that are lacking. Sometimes we can get tunnel-vision and forget what it is like approaching Bokeh as brand-new.

We do actively try to monitor SO for questions about Bokeh, but a more direct way to pose issues like this is to message the Bokeh mailing list at: bokeh@continuum.io Alternatively, submitting an issue on the GitHub issue tracker may be the best way to make sure an issue does not get overlooked. It is located at

https://github.com/bokeh/bokeh/issues

I have opened a PR for refreshing the docs before our upcoming release. I have added information about plot ranges and will add some other additional topics as well. You can monitor progress at:

https://github.com/bokeh/bokeh/pull/510

Expect these changes to show up on http://docs.bokeh.org later this week. Thanks for your feedback and thanks for your interest in Bokeh!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top