Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bokeh Range Set Only 1 Bound

I would expect the following code to set only the upper bound of the plot y range, however the lower bound is also inexplicably set to 0:

import bokeh.plotting as bkp
import numpy as np

bkp.output_file("/tmp/test_plot.html")
fig = bkp.figure(y_range=[None, 100]) # plot y range: 0-100
# fig = bkp.figure() # plot y range: 50-100
fig.line(np.linspace(0, 1, 200), np.random.random(200)*50+50) # number range: 50-100
bkp.save(fig)

Why does this happen? What's the easiest way to set only 1 range bound?

like image 459
user2561747 Avatar asked Jul 29 '16 00:07

user2561747


1 Answers

You are replacing the auto-ranging default DataRange1d with a "dumb" (non-auto ranging) Range1d. Set the end value of the default range that the plot creates, without replacing the entire range. Or alternatively, replace with a new DataRange1d:

from bokeh.models import DataRange1d
p = figure(y_range=DataRange1d(end=100))

or

p.y_range.end = 100
like image 190
bigreddot Avatar answered Sep 19 '22 23:09

bigreddot