# Interactive 3D surface plot - how to control Plotly's update behaviour

**URL:** https://community.plotly.com/t/interactive-3d-surface-plot-how-to-control-plotlys-update-behaviour/63786
**Category:** 📊 Plotly Python
**Created:** [May 6, 2022, 7:58am UTC](https://community.plotly.com/t/interactive-3d-surface-plot-how-to-control-plotlys-update-behaviour/63786 "2022-05-06T07:58:42Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Davide\_sd](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/davide_sd/32/12990_2.png) [@Davide\_sd](https://community.plotly.com/u/Davide_sd)
#### Post date: [May 6, 2022, 7:58am UTC](https://community.plotly.com/t/interactive-3d-surface-plot-how-to-control-plotlys-update-behaviour/63786/1 "2022-05-06T07:58:42Z")

</div>

I’m building an interactive plot with holoviz-panel (I’m required to use it): everything works fine, except that Plotly refreshes the figure every time I change a property. So when I move the slider by one tick, Plotly refreshes the figure 4 times, which is annoying to see.

Is there a way to ask Plotly to only refresh the figure at the end of the `update` function?

```auto
import numpy as np
import plotly.graph_objects as go
import panel as pn
pn.extension("plotly")

color_func = lambda x, y, z: x * y
f = lambda r, d: 10 * np.cos(r) * np.exp(-r * d)
x, y = np.mgrid[-7:7:100j, -7:7:100j]
r = np.sqrt(x **2 + y** 2)
z = f(r, 0.1)
surfacecolor = color_func(x, y, z)
fig = go.Figure([
    go.Surface(x=x, y=y, z=z, surfacecolor=surfacecolor, cmin=surfacecolor.min(), cmax=surfacecolor.max())
])
fig.update_layout({"scene": {"aspectmode": "cube"}})

slider = pn.widgets.FloatSlider(start=0, end=1, value=0.1)
@pn.depends(slider)
def update(d):
    surfacecolor = color_func(d * x, y, z)
    fig.data[0]["z"] = f(r, d)
    fig.data[0]["surfacecolor"] = surfacecolor
    fig.data[0]["cmin"] = surfacecolor.min()
    fig.data[0]["cmax"] = surfacecolor.max()
    return fig
pn.Column(slider, update)

```
