1

I'm using Bokeh for showing line graphs at my Django/Python web.

By default, the graphs start at the minimum value provided, but I want them to start always at 0 in the Y-axis.

For example, in the following example it starts at 167 in the Y-axis (the minimum value in that data set), but I wanted to start at 0.

graph

y_range seems to work fine if I want to define a minimum and a maximum, but I only want to define the minimum (0) and let the data "decide" the maximum.

I've tried using y_range=(0, None), min_border=0, start=0 and a bunch of other things, without success. ChatGPT keeps recommending me alternatives that don't really work or even exist.

This is my current code:

y = WHATEVER x = WHATEVER plot = figure(title='TITLE', x_axis_type='datetime', sizing_mode="stretch_width", max_width=600, height=400) plot.line(x, y, line_width=4) script, div = components(plot) 

1 Answer 1

2

ChatGPT keeps recommending me alternatives that don't really work or even exist.

This should not be surprising, ChatGPT is not a serious or reliable source of accurate information.

In any case, the only thing you need to do is set:

plot.y_range.start = 0 

with the default range (i.e. don't pass a range value to figure). That will keep auto-ranging for the upper y-axis but pin the start to 0.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! It works. It is better to add that line in some specific place/order? Or it doesn't matter? I've added it in a new line before "plot.line ..."
Barring anything unusual, it should not matter where it goes.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.