Show Sidebar Hide Sidebar

WebGL Heatmaps in R

How to make webGL based heatmaps in R with Plotly.

New to Plotly?

Plotly's R library is free and open source!
Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode.
We also have a quick-reference cheatsheet (new!) to help you get started!

Version Check

Version 4 of Plotly's R package is now available!
Check out this post for more information on breaking changes and new features available in this version.

## [1] '4.7.1'

WebGL Heatmap from an Image


# Image processing
url <- ""
tmpf <- tempfile()
data <- readJPEG(tmpf)
file.remove(tmpf) # remove the downloaded temp file

zdata = rowSums(data*255, dims = 2)

p <- plot_ly(
            z = zdata,
            colorscale = list(c(0,0.5,1),c("blue", "white", "red")),
            type = "heatmapgl"

# Create a shareable link to your chart
# Set up API credentials:
chart_link = api_create(p, filename="heatmap-webgl")


See for more information and options!

Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.