# Auto-range y when dragging the canvas

**URL:** <https://discourse.bokeh.org/t/auto-range-y-when-dragging-the-canvas/8346>\
**Category:** Community Support\
**Tags:** bokeh\
**Created:** [September 2, 2021, 11:38am UTC](https://discourse.bokeh.org/t/auto-range-y-when-dragging-the-canvas/8346 "2021-09-02T11:38:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![b02202040](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/b02202040/32/3839_2.png) [@b02202040](https://discourse.bokeh.org/u/b02202040)\
**Post date:** [September 2, 2021, 11:38am UTC](https://discourse.bokeh.org/t/auto-range-y-when-dragging-the-canvas/8346/1 "2021-09-02T11:38:59Z")

</div>

I’ve read most topic about the question I mentioned on the title, but I still don’t know how to do it.(most case is too complicated or the version is too old)

Like [this post](https://discourse.bokeh.org/t/dropdown-menu-event-resetting-y-size-on-the-second-plot/5442), the above figure is what I want.

Is there any simple example about this?  
Take the following code for a example,how to add this function?

```auto
from bokeh.plotting import figure, show

x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]

p = figure(title="Simple line example", x_axis_label="x", y_axis_label="y", tools=("xpan"))

p.line(x, y, legend_label="Temp.", line_width=2)

show(p)

```

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads.bokeh.org/original/2X/1/14eb24f9e10e4e9b78e3f10f66c04ffa96446e5a.svg) [@system](https://discourse.bokeh.org/u/system)\
**Post date:** [December 1, 2021, 11:39am UTC](https://discourse.bokeh.org/t/auto-range-y-when-dragging-the-canvas/8346/2 "2021-12-01T11:39:44Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
