You could use the type='heatmap' with add_annotations to add the y variable. Make sure showarrow = FALSE like this:

library(plotly)
library(dplyr)

TestData1 %>%
  plot_ly(x = ~Countries, y = ~variable, z = ~value, type = "heatmap", colors = c("#56B1F7", "#132B43")) %>%
  add_annotations(text = ~value, x = ~Countries, y = ~variable, showarrow = FALSE, font = list(color = "white")) %>%
  layout(xaxis = list(side = "top"), 
         yaxis = list(title = ""), 
         showlegend = FALSE) %>%
  hide_colorbar()

Created on 2023-03-17 with reprex v2.0.2

Answer from Quinten on Stack Overflow
๐ŸŒ
Plotly
plotly.com โ€บ r โ€บ heatmaps
Heatmaps in R
vals <- unique(scales::rescale(c(volcano))) o <- order(vals, decreasing = FALSE) cols <- scales::col_numeric("Blues", domain = NULL)(vals) colz <- setNames(data.frame(vals[o], cols[o]), NULL) fig <- plot_ly(z = volcano, colorscale = colz, type = "heatmap") fig
๐ŸŒ
Statistics Globe
statisticsglobe.com โ€บ home โ€บ learn r programming (tutorial & examples) | free introduction โ€บ create heatmap in r (3 examples) | base r, ggplot2 & plotly package
Create Heatmap in R (3 Examples) | Base R, ggplot2 & plotly Package
May 12, 2025 - As you can see based on Figure 7, the Greys specification created a heatmap in greyscale. Note that the plotly package show its graphics in the RStudio viewer instead of the RStudio plot window.
People also ask

How do I make a heatmap in R?
Pass a numeric matrix to a heatmap function. The base one-liner is heatmap(scale(mydata)); for a prettier, annotated version use pheatmap(scale(mydata), cutree_rows = 4). Always scale() the matrix first so one large-magnitude variable doesnโ€™t dominate the colors. Both functions cluster and reorder the rows and columns automatically.
๐ŸŒ
datanovia.com
datanovia.com โ€บ learn โ€บ machine learning โ€บ clustering heatmaps in r: heatmap, pheatmap & more
Clustering Heatmaps in R: heatmap, pheatmap & More โ€“ Datanovia
How do I make an interactive heatmap in R?
Use heatmaply() from the heatmaply package: heatmaply(scale(mydata), k_row = 4, k_col = 2). It renders through plotly, so you can hover over any cell to read its value and zoom into regions. It accepts the same clustering arguments as a static heatmap.
๐ŸŒ
datanovia.com
datanovia.com โ€บ learn โ€บ machine learning โ€บ clustering heatmaps in r: heatmap, pheatmap & more
Clustering Heatmaps in R: heatmap, pheatmap & More โ€“ Datanovia
What is the difference between pheatmap and heatmap?
Base heatmap() ships with R and needs no install, but its styling is plain and annotating it is fiddly (you build color side-bars by hand). pheatmap() (โ€œpretty heatmapโ€) gives cleaner defaults, draws nicer dendrograms, cuts the tree into groups with cutree_rows, and annotates rows and columns directly from a data frame with annotation_row / annotation_col. For most work, prefer pheatmap().
๐ŸŒ
datanovia.com
datanovia.com โ€บ learn โ€บ machine learning โ€บ clustering heatmaps in r: heatmap, pheatmap & more
Clustering Heatmaps in R: heatmap, pheatmap & More โ€“ Datanovia
๐ŸŒ
R Graph Gallery
r-graph-gallery.com โ€บ 215-interactive-heatmap-with-plotly.html
Plotly heatmap โ€“ the R Graph Gallery
You can build heatmaps specifying heatmap in the type argument. You have to provide a square matrix. Try: to zoom, to hover, to export to png and to slide axis. Double click to re-initialize. Note: You probably need to use the layout() function to increase the left margin (l for left). Otherwise row labels will be cut. # Load the plotly package library(plotly) # Data: mtcars: data <- as.matrix(mtcars) # basic heatmap p <- plot_ly(x=colnames(data), y=rownames(data), z = data, type = "heatmap") %>% layout(margin = list(l=120)) p # save the widget # library(htmlwidgets) # saveWidget(p, file=paste0( getwd(), "/HtmlWidget/plotlyHeatmap1.html"))
๐ŸŒ
Plotly
plotly.com โ€บ r โ€บ reference โ€บ heatmap
R Figure Reference: heatmap Traces
For example, "2016-10-13 09:15:23.456" with tickformat "%H~%M~%S./" would display "09~15~23.46"By default the values are formatted using `xaxis.hoverformat`. yhoverformat Parent: data[type=heatmap] Type: string Default: "" Sets the hover text formatting rulefor `y` using d3 formatting ...
๐ŸŒ
ProjectPro
projectpro.io โ€บ recipes โ€บ plot-heatmaps-plotly-r
How to plot heatmaps using plotly in R -
July 23, 2021 - Heat maps are plots that represent the data points in the form of a map, where the data points are shown with varying colors. Heat maps are widely used for visualizing complex statistical data. This recipe demonstrates an example on heatmaps in R.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ plotly โ€บ plotly_heatmap.htm
Plotly - Heatmap
] harvest = np.array( [ [0.8, 2.4, 2.5, 3.9, 0.0, 4.0, 0.0], [2.4, 0.0, 4.0, 1.0, 2.7, 0.0, 0.0], [1.1, 2.4, 0.8, 4.3, 1.9, 4.4, 0.0], [0.6, 0.0, 0.3, 0.0, 3.1, 0.0, 0.0], [0.7, 1.7, 0.6, 2.6, 2.2, 6.2, 0.0], [1.3, 1.2, 0.0, 0.0, 0.0, 3.2, 5.1], [0.1, 2.0, 0.0, 1.4, 0.0, 1.9, 6.3] ] ) trace = go.Heatmap( x = vegetables, y = farmers, z = harvest, type = 'heatmap', colorscale = 'Viridis' ) data = [trace] fig = go.Figure(data = data) iplot(fig)
Find elsewhere
๐ŸŒ
YouTube
youtube.com โ€บ watch
Heatmap in R (3 Examples) | Base R, ggplot2 & plotly Package | How to Create Heatmaps - YouTube
How to draw a heatmap in the R programming language. More details: https://statisticsglobe.com/heatmap-in-rR code of this video:##### Example dataset.seed(12...
Published: October 26, 2019
๐ŸŒ
Talgalili
talgalili.github.io โ€บ heatmaply
Interactive Cluster Heat Maps Using plotly and ggplot2 โ€ข heatmaply
Create interactive cluster heatmaps that can be saved as a stand- alone HTML file, embedded in R Markdown documents or in a Shiny app, and available in the RStudio viewer pane. Hover the mouse pointer over a cell to show details or drag a rectangle to zoom. A heatmap is a popular graphical ...
๐ŸŒ
Datanovia
datanovia.com โ€บ learn โ€บ machine learning โ€บ clustering heatmaps in r: heatmap, pheatmap & more
Clustering Heatmaps in R: heatmap, pheatmap & More โ€“ Datanovia
Use heatmaply() from the heatmaply package: heatmaply(scale(mydata), k_row = 4, k_col = 2). It renders through plotly, so you can hover over any cell to read its value and zoom into regions.
๐ŸŒ
CRAN
cran.r-project.org โ€บ web โ€บ packages โ€บ heatmaply โ€บ vignettes โ€บ heatmaply.html
Introduction to heatmaply - CRAN
Some aspects of heatmaply may not function identically when using plot_method = "plotly" relative to how they function when using plot_method = "ggplot" (the default), however in the majority of cases the output is equivalent. Using this option results in faster heatmaps capable of handling larger matrices. ... # Example for using RowSideColors x <- as.matrix(datasets::mtcars) rc <- colorspace::rainbow_hcl(nrow(x)) library("gplots")
๐ŸŒ
GitHub
github.com โ€บ talgalili โ€บ heatmaply
GitHub - talgalili/heatmaply: Interactive Heat Maps for R Using plotly ยท GitHub
Interactive heatmaps allow the inspection of specific value by hovering the mouse over a cell, as well as zooming into a region of the heatmap by dragging a rectangle around the relevant area. This work is based on the ggplot2 and plotly.js engine.
Starred by 406 users
Forked by 75 users
Languages: R 99.8% | Makefile 0.2%
๐ŸŒ
R Graph Gallery
r-graph-gallery.com โ€บ heatmap
Heatmap | the R Graph Gallery
A heatmap is a graphical representation of data where the individual values contained in a matrix are represented as colors. This page displays many examples built with R, both static and interactive
๐ŸŒ
Plotly
plotly.com โ€บ python โ€บ heatmaps
Heatmaps in Python
Plotly Express is the easy-to-use, high-level interface to Plotly, which operates on a variety of types of data and produces easy-to-style figures. With px.imshow, each value of the input array or data frame is represented as a heatmap pixel. The px.imshow() function can be used to display heatmaps (as well as full-color images, as its name suggests). It accepts both array-like objects like lists of lists and numpy or xarray arrays, as well as supported DataFrame objects. For more examples using px.imshow, including examples of faceting and animations, as well as full-color image display, see the the imshow documentation page.
๐ŸŒ
Plotly
plotly.com โ€บ chart-studio-help โ€บ make-a-heatmap
Heatmaps
After adding data, go to the 'Traces' section under the 'Structure' menu on the left-hand side. Choose the 'Type' of trace, then choose 'Heatmap' under 'Simple' chart type. Next, select 'X' and 'Y', and fill out the 'Z' values from their respective ...
๐ŸŒ
CRAN
cran.r-project.org โ€บ package=heatmaply
heatmaply: Interactive Cluster Heat Maps Using 'plotly' and 'ggplot2'
July 12, 2025 - 'Heatmaps' are used in many fields for visualizing observations, correlations, missing values patterns, and more. Interactive 'heatmaps' allow the inspection of specific value by hovering the mouse over a cell, as well as zooming into a region of the 'heatmap' by dragging a rectangle around the relevant area. This work is based on the 'ggplot2' and 'plotly.js' engine.
๐ŸŒ
Plotly
plotly.com โ€บ ggplot2 โ€บ heatmaps
Heatmaps in ggplot2
Over 10 examples of Heatmaps including changing color, size, log axes, and more in ggplot2.
๐ŸŒ
Plotly
community.plotly.com โ€บ plotly r, matlab, julia, net
Help with a Heatmap Graph - Plotly R, MATLAB, Julia, Net - Plotly Community Forum
November 19, 2022 - Can someone help me with graph like the one attached ? Any pointers that I can use to create this kind of graph. My data is each row in the graph is a column in the dataframe with its own category. I would like to create something like the attached and also create a legend for each category.
๐ŸŒ
Rdrr.io
rdrr.io โ€บ cran โ€บ heatmaply โ€บ man โ€บ heatmaply.html
heatmaply: Cluster heatmap based on plotly in heatmaply: Interactive Cluster Heat Maps Using 'plotly' and 'ggplot2'
October 7, 2023 - heatmaply(x, ...) heatmaply_na(x, grid_gap = 1, colors = c("grey80", "grey20"), ...) heatmaply_cor(x, limits = c(-1, 1), colors = cool_warm, ...) ## Default S3 method: heatmaply( x, colors = viridis(n = 256, alpha = 1, begin = 0, end = 1, option = "viridis"), limits = NULL, na.value = "grey50", ...