我正在尝试绘制一个heatmap
using R
's plotly
包,我希望为 y 轴刻度文本的特定标签设置特定的颜色。
这是一个示例数据集:
set.seed(1)
df <- reshape2::melt(matrix(rnorm(100),10,10,dimnames = list(paste0("G",1:10),paste0("S",1:10))))
这就是我正在尝试的:
library(plotly)
library(dplyr)
plot_ly(z=c(df$value),x=df$Var2,y=df$Var1,colors=grDevices::colorRamp(c("darkblue","gray","darkred")),type="heatmap",colorbar=list(title="Scaled Value",len=0.4)) %>%
layout(yaxis=list(title=list(color=c(rep("darkred",5),rep("darkblue",5)))))
It's not working since I'm getting:
![enter image description here](https://i.stack.imgur.com/tVcK6.png)
改变:yaxis=list(title=list(color=c(rep("darkred",5),rep("darkblue",5))))
To: yaxis=list(title=list(color=list(c(rep("darkred",5),rep("darkblue",5)))))
Or: yaxis=list(title=list(tickcolor=c(rep("darkred",5),rep("darkblue",5))))
Or: yaxis=list(title=list(tickcolor=list(c(rep("darkred",5),rep("darkblue",5)))))
似乎没有帮助。
任何想法?