d3heatmap: Interactive heat maps

June 24, 2015

(This article was first published on RStudio Blog, and kindly contributed to R-bloggers)

We’re pleased to announce d3heatmap, our new package for generating interactive heat maps using d3.js and htmlwidgets. Tal Galili, author of dendextend, collaborated with us on this package.

d3heatmap is designed to have a familiar feature set and API for anyone who has used heatmap or heatmap.2 to create static heatmaps. You can specify dendrogram, clustering, and scaling options in the same way.

d3heatmap includes the following features:

  • Shows the row/column/value under the mouse cursor
  • Click row/column labels to highlight
  • Drag a rectangle over the image to zoom in
  • Works from the R console, in RStudio, with R Markdown, and with Shiny




Here’s a very simple example (source: flowingdata):

url <-"http://datasets.flowingdata.com/ppg2008.csv"


You can easily customize the colors using the colors parameter. This can take an RColorBrewer palette name, a vector of colors, or a function that takes (potentially scaled) data points as input and returns colors.

Let’s modify the previous example by using the "Blues" colorbrewer palette, and dropping the clustering and dendrograms:

d3heatmap(nba_players, scale = "column", dendrogram = "none",
    color = "Blues")


If you want to use discrete colors instead of continuous, you can use the col_* functions from the scales package.

d3heatmap(nba_players, scale = "column", dendrogram = "none",
    color = scales::col_quantile("Blues", NULL, 5))

d3heatmapThanks to integration with the dendextend package, you can customize dendrograms with cluster colors:

d3heatmap(nba_players, colors = "Blues", scale = "col",
    dendrogram = "row", k_row = 3)

d3heatmapFor issue reports or feature requests, please see our GitHub repo.

To leave a comment for the author, please follow the link and comment on their blog: RStudio Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)