Interactive Heat Maps Using 'htmlwidgets' and 'D3.js'

Create interactive heat maps that are usable from the R console, in the 'RStudio' viewer pane, in 'R Markdown' documents, and in 'Shiny' apps. Hover the mouse pointer over a cell to show details, drag a rectangle to zoom, and click row/column labels to highlight.

If you are using a version of d3heatmap older than 0.4.0, please upgrade now! Previous versions put row and column names in the incorrect order!

This is an R package that implements a heatmap htmlwidget. It has the following features:

  • Highlight rows/columns by clicking axis labels
  • Click and drag over colormap to zoom in (click on colormap to zoom out)
  • Optional clustering and dendrograms, courtesy of base::heatmap

To install:

if (!require("devtools")) install.packages("devtools")

Like any htmlwidget, you can visualize a d3 heatmap directly from the R console:

d3heatmap(mtcars, scale = "column", colors = "Spectral")

You can also include them in R Markdown chunks, or use them in Shiny applications with the d3heatmapOutput and renderD3heatmap functions.

See ?d3heatmap for options.


  • Update smoke test so it doesn't break with next version of htmlwidgets
  • cellnote matrix was not being reordered properly
  • Update smoke test for new version of dendextend
  • d3heatmap - gains new parameters:

    • cellnote (and cellnote_scale) - for controlling the displayed value in the hover tooltip
    • digits - for controling the resolution of the value presented in the hover tooltip
    • labRow, labCol - character vectors with row and column labels to use;
    • cexRow, cexCol - to mimic the same values in heatmap.
    • revC - when dealing with a symmatric matrix
    • k_row/k_col - for coloring the branches of the dendrograms
  • Fix error in coloring code; accept palette integers

  • Remove invert_colors param, it no longer works

  • Remove heatmap_options parameter, it isn't needed

  • When scale is not "none" and colors param is not a function, scale colors to be centered at zero

  • dendToTree - now cleans NA inside the nodePar/edgePar sub items in the list.

  • d3heatmap - gains new parameters from stats::heatmap and gplots::heatmap.2 - including the ability to input the dendrogram that will be plotted. (currently it supports branches with colors, line width, and line type)

  • Added a basic Vignette

  • CRITICAL BUGFIX: The row and column labels were not ordered correctly in previous versions of d3heatmap--ouch! Thank you Sang Hoon Yi!

  • The vertical order of row data has been flipped, it now matches the output of stats::heatmap.

  • d3heatmap no longer depends on the leaflet package. It now depends on scales version 2.5 or later.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("d3heatmap") by Joe Cheng, a year ago

Report a bug at

Browse source code at

Authors: Joe Cheng [aut, cre], Tal Galili [aut], RStudio, Inc. [cph], Michael Bostock [ctb, cph] (D3.js library), Justin Palmer [ctb, cph] (d3.tip library)

Documentation:   PDF Manual  

GPL-3 | file LICENSE license

Imports scales, htmlwidgets, png, base64enc, dendextend, stats, grDevices

Suggests shiny, knitr

Imported by BayesianNetwork.

Suggested by dendextend.

See at CRAN