I have the following R code to plot a heatmap and annotate its values:
plot_ly(
x = colnames(correlations_cross),
y = rownames(correlations_cross),
z = correlations, type = "heatmap",
colorscale = list(c(0, "rgb(255, 0, 0)"), list(1, "rgb(0, 255, 0)")),
zauto = T,
zmin = 0.7,
zmax = 1
) %>%
add_annotations(x = colnames(correlations),
y = rownames(correlations),
text = correlations,
showarrow = FALSE,
ax = 20,
ay = -20)
The heatmap and colors are displayed correctly but annotations are only displayed correctly every third row of my heatmap. It seems to be alternating in a pattern: it displays first row correctly, then for the second row it grabs a value from 3rd column of the matrix, then 1st and 3rd. For the third row, it grabs a value from 2nd column, then 3rd and 1st. The fourth row is dispayed correctly and it keeps alternating like this.
โcorrelationsโ is a 25x3 matrix of correlation scores where rows and columns are named.
Any suggestion what could be wrong?