# Capture current zoom

**URL:** <https://discourse.holoviz.org/t/capture-current-zoom/6617>\
**Category:** HoloViews\
**Tags:** bokeh, holoviews\
**Created:** [December 18, 2023, 10:23pm UTC](https://discourse.holoviz.org/t/capture-current-zoom/6617 "2023-12-18T22:23:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scooter](https://discourse.holoviz.org/letter_avatar_proxy/v4/letter/s/b5a626/32.png) [@Scooter](https://discourse.holoviz.org/u/Scooter)\
**Post date:** [December 18, 2023, 10:23pm UTC](https://discourse.holoviz.org/t/capture-current-zoom/6617/1 "2023-12-18T22:23:28Z")

</div>

Is it possible to capture the current zoom area of a plot, update the plot, and reapply the zoom area? I am working on time series data and I have Panel widgets that update a plot. When the plot is redrawn the zoom is lost forcing the user to zoom in again which makes things tedious. Below is an example of the plot. The first image show the plot as it is initially drawn. The second show a comfortable zoom level. When I use a widget that updates the plot, the plot changes from the comfortable zoom back to the initial plot view.

 ![image](https://discourse.holoviz.org/uploads/default/original/2X/0/05519594b5a1b0281d10e579aa3fe32be8974037.png)

---

<div class="post-metadata">

**Author:** ![ahuang11](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/ahuang11/32/4947_2.png) [@ahuang11](https://discourse.holoviz.org/u/ahuang11)\
**Post date:** [December 19, 2023, 12:43am UTC](https://discourse.holoviz.org/t/capture-current-zoom/6617/2 "2023-12-19T00:43:53Z")

</div>

I think you’re looking for DynamicMap; see  
[https://pydeas.readthedocs.io/en/latest/holoviz\_interactions/tips\_and\_tricks.html#Wrap-DynamicMap-around-Panel-methods-to-maintain-extents-and-improve-runtime](https://pydeas.readthedocs.io/en/latest/holoviz_interactions/tips_and_tricks.html#Wrap-DynamicMap-around-Panel-methods-to-maintain-extents-and-improve-runtime)

Also related:  
[https://panel.holoviz.org/reference/panes/HoloViews.html#widgets](https://panel.holoviz.org/reference/panes/HoloViews.html#widgets)

> [@Parameterized class that keeps Bokeh line plot x and y range](https://discourse.holoviz.org/t/parameterized-class-that-keeps-bokeh-line-plot-x-and-y-range/6479/2):
>
> A DynamicMap has special code for figuring out in-place minimal updates, precisely to avoid having to re-render the whole plot as you see in this case. I don’t know of any direct equivalent to that for pure bokeh plots, but I’d guess there’s some way to use a Bokeh JS link ([JavaScript callbacks — Bokeh 2.4.2 Documentation](https://docs.bokeh.org/en/2.4.2/docs/user_guide/interaction/callbacks.html)) to wire the widget to the position of that marker.

However, if you do need the zoom\_range,

> [@Getting current x\_range values after zooming](https://discourse.holoviz.org/t/getting-current-x-range-values-after-zooming/3583/2):
>
> Hi @Ahmet, The following posts may be of use here, reads like you might be after rangexy stream: [https://holoviews.org/reference/streams/bokeh/RangeXY.html](https://holoviews.org/reference/streams/bokeh/RangeXY.html)[https://discourse.holoviz.org/t/keep-zoom-level-when-changing-between-variables-in-a-scatter-plot/1120](https://discourse.holoviz.org/t/keep-zoom-level-when-changing-between-variables-in-a-scatter-plot/1120)[https://discourse.holoviz.org/t/dynamically-replacing-overlaid-image-s-on-a-tile-map-without-resetting-the-whole-map-to-default-zoom/2203](https://discourse.holoviz.org/t/dynamically-replacing-overlaid-image-s-on-a-tile-map-without-resetting-the-whole-map-to-default-zoom/2203)[https://discourse.holoviz.org/t/keep-zoom-while-changing-variables-and-allow-reset/2148/6](https://discourse.holoviz.org/t/keep-zoom-while-changing-variables-and-allow-reset/2148/6) Thanks,…

---

<div class="post-metadata">

**Author:** ![Scooter](https://discourse.holoviz.org/letter_avatar_proxy/v4/letter/s/b5a626/32.png) [@Scooter](https://discourse.holoviz.org/u/Scooter)\
**Post date:** [December 21, 2023, 8:05pm UTC](https://discourse.holoviz.org/t/capture-current-zoom/6617/3 "2023-12-21T20:05:22Z")

</div>

@ahuang11 Thank you very much! That fixed my problem.
