Very slow heatmap color scale change with slider

The following code works to change the “min” of the color scale of a heatmap with a slider

Live demo

But it is very slow. How to have a more responsive / faster change of the color scale with a slider?

<script src=""></script>
<div id="myDiv"></div>
var z = [], steps = [], i;
for (i = 0; i < 500; i++) 
    z.push(Array.from({length: 800}, () => Math.floor(Math.random() * 100)));  
for (i = 0; i < 100; i++)
    steps.push({ label: i, method: 'restyle', args: ['zmin', i]});
Plotly.newPlot('myDiv',  [{z: z, colorscale: 'Jet', type: 'heatmap'}], {sliders: [{steps: steps}]});

Hello @stamljf,

I dont think that there is a quicker way to do what you are trying to do.

Thank you for your answer!

I hoped it was possible to speed up the rendering.

By the way, are some parts of Plotly.JS using WASM? If so, I can imagine it could boost the rendreing speed sometimes?

Wait, I figured it out.

Use heatmapgl instead of heatmap. This allows it to use webgl instead of svg. :slight_smile:

1 Like


The second seems to apply a different smoothing (or alsiasing ?)

Do you see a difference in performance ?

Yes, the gl is much quicker, probably about half of the time to move the slider.

Yeah, there are some differences, but the performance boost is noticeable.