Search code examples
pythonpython-3.xplotlyheatmap

Plotly Heatmap has Limit on Data Size


I’m trying to create a (very) large heatmap using plotly. My dataset is of shape (10, 85000), and I noticed that I can’t display heatmaps when the row size is greater than 65k:

row_size = 65000  # change this to 66000 and the figure is displayed empty
z = np.random.randint(0, 101, size=(10, row_size))
heatmap = go.Heatmap(z=z,
                     colorbar=dict(
                         thickness=25,
                     ))
fig = go.Figure(data=[heatmap])
fig.update_layout(width=1500, height=500)
fig.show()

Is there a way to increase this limit?


Solution

  • No. This limitation is actually the maximum canvas size, which depends on the browser and environment.

    Exceeding the maximum dimensions or area renders the canvas unusable — drawing commands will not work (MDN).

    The table below is generated using https://jhildenbiddle.github.io/canvas-size :

    Desktop

    Browser (OS) Max Width Max Height Max Area (Total)
    Chrome 73+ (Mac, Win) 65,535 65,535 16,384 x 16,384 (268,435,456)
    Chrome < 73 (Mac, Win) 32,767 32,767 16,384 x 16,384 (268,435,456)
    Edge 80+ (Mac, Win) 65,535 65,535 16,384 x 16,384 (268,435,456)
    Edge 15 - 18 (Win) 16,384 16,384 16,384 x 16,384 (268,435,456)
    Firefox 122+ (Mac, Win) 32,767 32,767 23,168 x 23,168 (536,756,224)
    Firefox < 122 (Mac, Win) 32,767 32,767 11,180 x 11,180 (124,992,400)
    IE 11 (Win) 16,384 16,384 8,192 x 8,192 (67,108,864)
    IE 9 - 10 (Win) 8,192 8,192 8,192 x 8,192 (67,108,864)
    Safari 5+ (Mac) 4,194,303 8,388,607 16,384 x 16,384 (268,435,456)

    Mobile

    Browser (OS) Max Width Max Height Max Area (Total)
    Chrome 91+ (Android 8 - 11) 65,535 65,535 16,384 x 16,384 (268,435,456)
    Chrome 91+ (Android 7) 65,535 65,535 14,188 x 14,188 (201,299,344)
    Chrome 91+ (Android 6) 65,535 65,535 16,384 x 16,384 (268,435,456)
    Chrome 91+ (Android 5) 65,535 65,535 11,180 x 11,180 (124,992,400)
    Chrome 68+ (Android 7.1 - 9) 32,767 32,767 14,188 x 14,188 (201,299,344)
    Chrome 68+ (Android 6) 32,767 32,767 10,836 x 10,836 (117,418,896)
    Chrome 68+ (Android 5) 32,767 32,767 11,402 x 11,402 (130,005,604)
    IE (Windows Phone 8.x) 4,096 4,096 4,096 x 4,096 (16,777,216)
    Mobile Safari 9+ 4,194,303 8,388,607 4,096 x 4,096 (16,777,216)