{"id":15817,"date":"2020-04-19T11:54:13","date_gmt":"2020-04-19T10:54:13","guid":{"rendered":"https:\/\/www.datanovia.com\/en\/?p=15817"},"modified":"2020-04-19T11:54:13","modified_gmt":"2020-04-19T10:54:13","slug":"how-to-create-a-beautiful-interactive-heatmap-in-r","status":"publish","type":"post","link":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/","title":{"rendered":"How to Create a Beautiful Interactive Heatmap in R"},"content":{"rendered":"<div id=\"rdoc\">\n<p>This articles describes how to create and customize an <strong>interactive heatmap in R<\/strong> using the <strong>heatmaply<\/strong> R package, which is based on the <em>ggplot2<\/em> and <em>plotly.js<\/em> engine.<\/p>\n<p>Contents:<\/p>\n<div id=\"TOC\">\n<ul>\n<li><a href=\"#prerequisites\">Prerequisites<\/a><\/li>\n<li><a href=\"#data-preparation\">Data preparation<\/a><\/li>\n<li><a href=\"#basic-heatmap\">Basic heatmap<\/a><\/li>\n<li><a href=\"#split-rows-and-columns-dendrograms-into-k-groups\">Split rows and columns dendrograms into k groups<\/a><\/li>\n<li><a href=\"#change-color-palettes\">Change color palettes<\/a><\/li>\n<li><a href=\"#customize-dendrograms-using-dendextend\">Customize dendrograms using dendextend<\/a><\/li>\n<li><a href=\"#add-annotation-based-on-additional-factors\">Add annotation based on additional factors<\/a><\/li>\n<li><a href=\"#add-text-annotations\">Add text annotations<\/a><\/li>\n<li><a href=\"#add-custom-hover-text\">Add custom hover text<\/a><\/li>\n<li><a href=\"#saving-your-heatmaply-into-a-file\">Saving your heatmaply into a file<\/a><\/li>\n<li><a href=\"#references\">References<\/a><\/li>\n<\/ul>\n<\/div>\n<div id=\"prerequisites\" class=\"section level2\">\n<h2>Prerequisites<\/h2>\n<p>Install the required R package:<\/p>\n<pre class=\"r\"><code>install.packages(\"heatmaply\")<\/code><\/pre>\n<p>Load the package:<\/p>\n<pre class=\"r\"><code>library(\"heatmaply\")<\/code><\/pre>\n<\/div>\n<div id=\"data-preparation\" class=\"section level2\">\n<h2>Data preparation<\/h2>\n<p>Normalize the data to make the variables values comparable.<\/p>\n<pre class=\"r\"><code>df &lt;- normalize(mtcars)<\/code><\/pre>\n<div class=\"warning\">\n<p>Note that, other data transformation functions are <code>scale()<\/code> (for standardization), <code>percentize()<\/code> [for percentile transformation; available in the heatmaply R package]. Read more: <a href=\"https:\/\/www.datanovia.com\/en\/blog\/how-to-normalize-and-standardize-data-in-r-for-great-heatmap-visualization\/\">How to Normalize and Standardize Data in R for Great Heatmap Visualization<\/a>.<\/p>\n<\/div>\n<\/div>\n<div id=\"basic-heatmap\" class=\"section level2\">\n<h2>Basic heatmap<\/h2>\n<pre class=\"r\"><code>heatmaply(df)<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"600\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/interactive-heatmap-in-r-heatmaply-basic-heatmap.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<p>Heatmaply has also the option to produce a static heatmap using the <code>ggheatmap<\/code> R function:<\/p>\n<pre class=\"r\"><code>ggheatmap(df)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/interactive-heatmap-in-r-ggheatmap-1.png\" width=\"576\" \/><\/p>\n<div class=\"block\">\n<p>Note that, <code>heatmaply<\/code> uses the <a href=\"https:\/\/www.datanovia.com\/en\/blog\/seriation-in-r-how-to-optimally-order-objects-in-a-data-matrice\/\">seriation package<\/a> to find an optimal ordering of rows and columns.<\/p>\n<p>The function <code>heatmaply()<\/code> has an option named <code>seriate<\/code>, which possible values include:<\/p>\n<ul>\n<li><code>\u201cOLO\u201d<\/code> (Optimal leaf ordering): This is the default value.<\/li>\n<li><code>\u201cmean\u201d<\/code>: This option gives the output we would get by default from heatmap functions in other packages such as <code>gplots::heatmap.2()<\/code>.<\/li>\n<li><code>\u201cnone\u201d<\/code>: This option gives us the dendrograms without any rotation. The result is similar to what we would get by default from hclust.<\/li>\n<\/ul>\n<\/div>\n<p><strong>Replicating the dendrogram ordering of gplots::heatmap.2()<\/strong>.<\/p>\n<ul>\n<li>Create a heatmap using the <code>gplots<\/code> R package:<\/li>\n<\/ul>\n<pre class=\"r\"><code>gplots::heatmap.2(\r\n  as.matrix(df),\r\n  trace = \"none\",\r\n  col = viridis(100),\r\n  key = FALSE\r\n)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/interactive-heatmap-in-r-heatmap-using-gplots-1.png\" width=\"576\" \/><\/p>\n<ul>\n<li>Create a similar version using the <code>heatmaply<\/code> R package:<\/li>\n<\/ul>\n<pre class=\"r\"><code>heatmaply(\r\n  as.matrix(df),\r\n  seriate = \"mean\", \r\n  row_dend_left = TRUE,\r\n  plot_method = \"plotly\"\r\n)<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"600\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/interactive-heatmap-in-r-gplots-like-heatmap-using-heatmaply.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<\/div>\n<div id=\"split-rows-and-columns-dendrograms-into-k-groups\" class=\"section level2\">\n<h2>Split rows and columns dendrograms into k groups<\/h2>\n<p>The k-means algorithm is used.<\/p>\n<pre class=\"r\"><code>heatmaply(\r\n  df,\r\n  k_col = 2, \r\n  k_row = 2\r\n)<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"600\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/interactive-heatmap-in-r-heatmaply-split-dendrograms.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<\/div>\n<div id=\"change-color-palettes\" class=\"section level2\">\n<h2>Change color palettes<\/h2>\n<p>The default color palette is <code>viridis<\/code>. Other excellent color palettes are available in the packages <a href=\"https:\/\/cran.r-project.org\/package=cetcolor\">cetcolor<\/a> and <a href=\"https:\/\/www.datanovia.com\/en\/blog\/the-a-z-of-rcolorbrewer-palette\/\">RColorBrewer<\/a>.<\/p>\n<p>Use the viridis colors with the option \u201cmagma\u201d:<\/p>\n<pre class=\"r\"><code>heatmaply(\r\n  df,\r\n  colors = viridis(n = 256,  option = \"magma\"),\r\n  k_col = 2, \r\n  k_row = 2\r\n)<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"600\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/interactive-heatmap-in-r-heatmaply-use-viridis-colors.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<p>Use the <code>RColorBrewer<\/code> palette :<\/p>\n<pre class=\"r\"><code>library(RColorBrewer)\r\nheatmaply(\r\n  df,\r\n  colors = colorRampPalette(brewer.pal(3, \"RdBu\"))(256),\r\n  k_col = 2, \r\n  k_row = 2\r\n)<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"600\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/interactive-heatmap-in-r-heatmaply-use-rcolorbrewer-colors.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<p>Specify customized gradient colors using the function <code>scale_fill_gradient2()<\/code> [ggplot2 package].<\/p>\n<pre class=\"r\"><code>gradient_col &lt;- ggplot2::scale_fill_gradient2(\r\n   low = \"blue\", high = \"red\", \r\n    midpoint = 0.5, limits = c(0, 1)\r\n  )\r\nheatmaply(\r\n  df,\r\n  scale_fill_gradient_fun = gradient_col\r\n)<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"600\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/interactive-heatmap-in-r-heatmaply-use-custom-colors.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<\/div>\n<div id=\"customize-dendrograms-using-dendextend\" class=\"section level2\">\n<h2>Customize dendrograms using dendextend<\/h2>\n<p>A user can supply their own dendrograms for the rows\/columns of the heatmaply using the <code>Rowv<\/code> and the <code>Colv<\/code> parameters:<\/p>\n<pre class=\"r\"><code>library(dendextend)\r\n# Create dendrogram for rows\r\nmycols &lt;- c(\"#2E9FDF\", \"#00AFBB\", \"#E7B800\", \"#FC4E07\")\r\nrow_dend &lt;-  df %&gt;%\r\n  dist() %&gt;%\r\n  hclust() %&gt;%\r\n  as.dendrogram() %&gt;%\r\n  set(\"branches_lwd\", 1) %&gt;% \r\n  set(\"branches_k_color\", mycols[1:3], k = 3) \r\n\r\n# Create dendrogram for columns\r\ncol_dend &lt;-  df %&gt;%\r\n  t() %&gt;%\r\n  dist() %&gt;%\r\n  hclust() %&gt;%\r\n  as.dendrogram() %&gt;%\r\n  set(\"branches_lwd\", 1) %&gt;% \r\n  set(\"branches_k_color\", mycols[1:2], k = 2)<\/code><\/pre>\n<pre class=\"r\"><code># Visualize the heatmap\r\nheatmaply(\r\n  df,\r\n  Rowv = row_dend,\r\n  Colv = col_dend\r\n)<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"600\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/interactive-heatmap-in-r-heatmaply-customized-dendrograms-using-dendextend.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<\/div>\n<div id=\"add-annotation-based-on-additional-factors\" class=\"section level2\">\n<h2>Add annotation based on additional factors<\/h2>\n<p>The following R code adds annotation on column and row sides:<\/p>\n<pre class=\"r\"><code>heatmaply(\r\n  df[, -c(8, 9)],\r\n  col_side_colors = c(rep(0, 5), rep(1, 4)),\r\n  row_side_colors = df[, 8:9]\r\n)<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"600\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/interactive-heatmap-in-r-heatmaply-adding-annotation.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<\/div>\n<div id=\"add-text-annotations\" class=\"section level2\">\n<h2>Add text annotations<\/h2>\n<p>By default, the colour of the text on each cell is chosen to ensure legibility, with black text shown over light cells and white text shown over dark cells.<\/p>\n<pre class=\"r\"><code>heatmaply(df, cellnote = mtcars)<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"600\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/interactive-heatmap-in-r-heatmaply-add-text-annotation.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<\/div>\n<div id=\"add-custom-hover-text\" class=\"section level2\">\n<h2>Add custom hover text<\/h2>\n<pre class=\"r\"><code>mat &lt;- df\r\nmat[] &lt;- paste(\"This cell is\", rownames(mat))\r\nmat[] &lt;- lapply(colnames(mat), function(colname) {\r\n    paste0(mat[, colname], \", \", colname)\r\n})<\/code><\/pre>\n<pre class=\"r\"><code>heatmaply(\r\n  df,\r\n  custom_hovertext = mat\r\n)<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"600\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/interactive-heatmap-in-r-heatmaply-custom-hover-text-.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<\/div>\n<div id=\"saving-your-heatmaply-into-a-file\" class=\"section level2\">\n<h2>Saving your heatmaply into a file<\/h2>\n<p>Create an interactive html file:<\/p>\n<pre class=\"r\"><code>dir.create(\"folder\")\r\nheatmaply(mtcars, file = \"folder\/heatmaply_plot.html\")\r\nbrowseURL(\"folder\/heatmaply_plot.html\")<\/code><\/pre>\n<p>Saving a static file (png\/jpeg\/pdf). Before the first time using this code you may need to first run: <code>webshot::install_phantomjs()<\/code> or to install <a href=\"https:\/\/github.com\/plotly\/orca\">plotly\u2019s orca<\/a> program.<\/p>\n<pre class=\"r\"><code>dir.create(\"folder\")\r\nheatmaply(mtcars, file = \"folder\/heatmaply_plot.png\")\r\nbrowseURL(\"folder\/heatmaply_plot.png\")<\/code><\/pre>\n<p>Save the file, without plotting it in the console:<\/p>\n<pre class=\"r\"><code>tmp &lt;- heatmaply(mtcars, file = \"folder\/heatmaply_plot.png\")\r\nrm(tmp)<\/code><\/pre>\n<\/div>\n<div id=\"references\" class=\"section level2\">\n<h2>References<\/h2>\n<ul>\n<li><a href=\"https:\/\/cran.r-project.org\/web\/packages\/heatmaply\/vignettes\/heatmaply.html\">Introduction to heatmaply<\/a><\/li>\n<\/ul>\n<\/div>\n<\/div>\n<p><!--end rdoc--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This articles describes how to create and customize an interactive heatmap in R using the heatmaply R package, which is based on the ggplot2 and plotly.js engine. Contents: Prerequisites Data [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":15715,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rating_form_position":"","rating_results_position":"","mr_structured_data_type":"","footnotes":""},"categories":[123,134],"tags":[363,135],"class_list":["post-15817","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cluster-analysis","category-data-visualization","tag-heatmap","tag-interactive-visualization"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Create a Beautiful Interactive Heatmap in R - Datanovia<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create a Beautiful Interactive Heatmap in R - Datanovia\" \/>\n<meta property=\"og:description\" content=\"This articles describes how to create and customize an interactive heatmap in R using the heatmaply R package, which is based on the ggplot2 and plotly.js engine. Contents: Prerequisites Data [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Datanovia\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-19T10:54:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/heatmaply-interactive-heatmap-in-r.gif\" \/>\n\t<meta property=\"og:image:width\" content=\"598\" \/>\n\t<meta property=\"og:image:height\" content=\"468\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/gif\" \/>\n<meta name=\"author\" content=\"Alboukadel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alboukadel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/\"},\"author\":{\"name\":\"Alboukadel\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e\"},\"headline\":\"How to Create a Beautiful Interactive Heatmap in R\",\"datePublished\":\"2020-04-19T10:54:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/\"},\"wordCount\":421,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/heatmaply-interactive-heatmap-in-r.gif\",\"keywords\":[\"Heatmap\",\"Interactive Visualization\"],\"articleSection\":[\"Cluster Analysis\",\"Data Visualization\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/\",\"name\":\"How to Create a Beautiful Interactive Heatmap in R - Datanovia\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/heatmaply-interactive-heatmap-in-r.gif\",\"datePublished\":\"2020-04-19T10:54:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#primaryimage\",\"url\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/heatmaply-interactive-heatmap-in-r.gif\",\"contentUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/heatmaply-interactive-heatmap-in-r.gif\",\"width\":598,\"height\":468,\"caption\":\"Interactive Heatmap in R using heatmaply\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.datanovia.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create a Beautiful Interactive Heatmap in R\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\",\"url\":\"https:\/\/www.datanovia.com\/en\/\",\"name\":\"Datanovia\",\"description\":\"Data Mining and Statistics for Decision Support\",\"publisher\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.datanovia.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\",\"name\":\"Datanovia\",\"url\":\"https:\/\/www.datanovia.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png\",\"contentUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png\",\"width\":98,\"height\":99,\"caption\":\"Datanovia\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e\",\"name\":\"Alboukadel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g\",\"caption\":\"Alboukadel\"},\"url\":\"https:\/\/www.datanovia.com\/en\/blog\/author\/kassambara\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create a Beautiful Interactive Heatmap in R - Datanovia","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/","og_locale":"en_US","og_type":"article","og_title":"How to Create a Beautiful Interactive Heatmap in R - Datanovia","og_description":"This articles describes how to create and customize an interactive heatmap in R using the heatmaply R package, which is based on the ggplot2 and plotly.js engine. Contents: Prerequisites Data [&hellip;]","og_url":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/","og_site_name":"Datanovia","article_published_time":"2020-04-19T10:54:13+00:00","og_image":[{"width":598,"height":468,"url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/heatmaply-interactive-heatmap-in-r.gif","type":"image\/gif"}],"author":"Alboukadel","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Alboukadel","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#article","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/"},"author":{"name":"Alboukadel","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e"},"headline":"How to Create a Beautiful Interactive Heatmap in R","datePublished":"2020-04-19T10:54:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/"},"wordCount":421,"commentCount":0,"publisher":{"@id":"https:\/\/www.datanovia.com\/en\/#organization"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/heatmaply-interactive-heatmap-in-r.gif","keywords":["Heatmap","Interactive Visualization"],"articleSection":["Cluster Analysis","Data Visualization"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/","url":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/","name":"How to Create a Beautiful Interactive Heatmap in R - Datanovia","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#primaryimage"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/heatmaply-interactive-heatmap-in-r.gif","datePublished":"2020-04-19T10:54:13+00:00","breadcrumb":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#primaryimage","url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/heatmaply-interactive-heatmap-in-r.gif","contentUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/heatmaply-interactive-heatmap-in-r.gif","width":598,"height":468,"caption":"Interactive Heatmap in R using heatmaply"},{"@type":"BreadcrumbList","@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-interactive-heatmap-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.datanovia.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to Create a Beautiful Interactive Heatmap in R"}]},{"@type":"WebSite","@id":"https:\/\/www.datanovia.com\/en\/#website","url":"https:\/\/www.datanovia.com\/en\/","name":"Datanovia","description":"Data Mining and Statistics for Decision Support","publisher":{"@id":"https:\/\/www.datanovia.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.datanovia.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.datanovia.com\/en\/#organization","name":"Datanovia","url":"https:\/\/www.datanovia.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png","contentUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png","width":98,"height":99,"caption":"Datanovia"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e","name":"Alboukadel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g","caption":"Alboukadel"},"url":"https:\/\/www.datanovia.com\/en\/blog\/author\/kassambara\/"}]}},"multi-rating":{"mr_rating_results":[]},"_links":{"self":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/15817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/comments?post=15817"}],"version-history":[{"count":1,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/15817\/revisions"}],"predecessor-version":[{"id":15818,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/15817\/revisions\/15818"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media\/15715"}],"wp:attachment":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media?parent=15817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/categories?post=15817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/tags?post=15817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}