我正在尝试在轮廓图中设置Rainbow色标,但不知道该怎么做。我这样启动代码:
p = plot_ly(type = 'contour', z = matrix,
x = fracao, y = -prof, colorscale = 'Rainbow',
autocontour = F, contours = list(start = 0, end = 12, size = 3, showlabels = T))
%>% colorbar(title = "Wt. %"))
但是在阅读了本主题之后... Colorscale = 'Rainbow' in plot_ly doesn't work
我将代码更改为:
p = plot_ly(type = 'contour', z = matrix,
x = fracao, y = -prof, colorscale = cbind(seq(0, 1, by=1/(length(z) -1)), rainbow(length(z))),
autocontour = F, contours = list(start = 0, end = 12, size = 3, showlabels = T))
%>% colorbar(title = "Wt. %"))
答案 0 :(得分:0)
好的,我找到了解决问题的方法...非常简单:
colorscale = list(c(0, 0.5, 1), c('blue', 'yellow', 'red'))
您可以添加更多间隔(0、0.2、0.4 ...),并根据需要将颜色字符串名称更改为rgb或HTML。