# Is infinite figure zoom possible (i.e. callback to refresh figure data)?

**URL:** https://discourse.julialang.org/t/is-infinite-figure-zoom-possible-i-e-callback-to-refresh-figure-data/10468
**Category:** Visualization
**Created:** [April 21, 2018, 3:08pm UTC](https://discourse.julialang.org/t/is-infinite-figure-zoom-possible-i-e-callback-to-refresh-figure-data/10468 "2018-04-21T15:08:42Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![NickNack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nicknack/32/1792_2.png) [@NickNack](https://discourse.julialang.org/u/NickNack)
#### Post date: [April 21, 2018, 3:08pm UTC](https://discourse.julialang.org/t/is-infinite-figure-zoom-possible-i-e-callback-to-refresh-figure-data/10468/1 "2018-04-21T15:08:42Z")

</div>

Several of the backends to Plots.jl provide interactive pan & zoom. However (as far as I can tell) they only work with the original figure data, so the figure looks pixelized and ugly when zoomed in sufficiently. Is there any backend that allows a callback function to refresh the figure using the zoomed axes so that everything still looks pretty when zoomed?

If this is impossible with Plots.jl, is there another way to do it? I don’t need advanced chart types, just scatter plots and heatmaps.

---

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [April 21, 2018, 3:39pm UTC](https://discourse.julialang.org/t/is-infinite-figure-zoom-possible-i-e-callback-to-refresh-figure-data/10468/2 "2018-04-21T15:39:59Z")

</div>

The plotly(js) and pyplot backends both allow that, as does inspectdr - but you need the native plotting window (plot from the REPL, or use `gui()` in Juno, though there’s been issues with that).

---

<div class="post-metadata">

### Author: ![NickNack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nicknack/32/1792_2.png) [@NickNack](https://discourse.julialang.org/u/NickNack)
#### Post date: [April 21, 2018, 4:13pm UTC](https://discourse.julialang.org/t/is-infinite-figure-zoom-possible-i-e-callback-to-refresh-figure-data/10468/3 "2018-04-21T16:13:51Z")

</div>

That’s great! Is there a simple example that shows how to define the callback in say plotlyjs? I couldn’t find anything in the documentation. If there is none written yet and it’s too hard to explain then please just tell me what the relevant parameters are called and I’ll try to figure it out from the source code.

---

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [April 21, 2018, 4:16pm UTC](https://discourse.julialang.org/t/is-infinite-figure-zoom-possible-i-e-callback-to-refresh-figure-data/10468/4 "2018-04-21T16:16:49Z")

</div>

Sorry you can’t define callback with the backends. That is a Plots issue. But they allow infinite zoom natively.

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [April 21, 2018, 8:35pm UTC](https://discourse.julialang.org/t/is-infinite-figure-zoom-possible-i-e-callback-to-refresh-figure-data/10468/5 "2018-04-21T20:35:19Z")

</div>

Zooming also works with the pyplot() backend (from the REPL). But the axis ticks are not redrawn when zooming in (neither for plotly nor pyplot). (Or is that an issue with my setup?) That is one of the reasons why I often end up using straight PyPlot.jl, where that works.

---

<div class="post-metadata">

### Author: ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)
#### Post date: [April 21, 2018, 11:58pm UTC](https://discourse.julialang.org/t/is-infinite-figure-zoom-possible-i-e-callback-to-refresh-figure-data/10468/6 "2018-04-21T23:58:59Z")

</div>

> [@mauro3](#):
>
> Zooming also works with the pyplot() backend (from the REPL). But the axis ticks are not redrawn when zooming in (neither for plotly nor pyplot)

On the latest Plots.jl master, you can use `ticks=:native`, courtesy of @apalugniok.

> [@NickNack](#):
>
> Several of the backends to Plots.jl provide interactive pan & zoom. However (as far as I can tell) they only work with the original figure data, so the figure looks pixelized and ugly when zoomed in sufficiently. Is there any backend that allows a callback function to refresh the figure using the zoomed axes so that everything still looks pretty when zoomed?

I believe you could use [PlotlyWebIO.jl](https://github.com/sglyon/PlotlyWebIO.jl), and [addtrace](https://github.com/sglyon/PlotlyWebIO.jl/pull/5) to add more data to the plot upon zooming (Plotly has events you can hook into). Beware: PlotlyWebIO.jl is unreleased and undocumented at the moment. I was able to do all I wanted (interactive modification of data using the selection tool), but it took a lot of digging into the Plotly web API, and into WebIO.jl.
