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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With