我正在尝试在等高线图中设置彩虹色阶,但不知道该怎么做。我这样开始我的代码:
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. %"))
最佳答案
好的,我找到了解决问题的方法...非常简单:
colorscale = list(c(0, 0.5, 1), c('blue', 'yellow', 'red'))
如果需要,您可以添加更多间隔(0、0.2、0.4...)并将颜色字符串名称更改为 rgb 或 HTML。
关于r - 如何手动设置等值线图 R-Plotly 中的色标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55164195/