R Plot_ly : 如何更改 colorbar 调色板和 colorthreshold 值?
R Plot_ly : How to change colorbar color palette and colorthreshold values?
我正在尝试绘制 3D 散点图(前 3 个维度的 PCA 散点图),但我找不到更改 plot_ly 上的颜色条的方法。
代码在下面,这是我得到的,但我希望它从红色(最负值)到绿色(上限值),转折点(淡粉色)为 0 而不是+18‰好像在图上。
你能帮帮我吗?
ind5<-get_pca_ind(PCA_data5)
a<-ind5$coord[,1]
b<-ind5$coord[,2]
c<-ind5$coord[,3]
d<-Interviews$`Annual_SOC_rate_‰`
f1 <- list(
family = "Times New Roman",
size = 20,
color = "black")
fig <- plot_ly(Interviews, x = ~a, y = ~b, z = ~c,
marker = list(color = ~d,
colorbar=list(tickfont=f1),
showscale = TRUE))
fig <- fig %>% add_markers()
fig <- fig %>% layout(scene = list(xaxis = list(title = 'Dim1 (18.8%)',
titlefont = f1,
tickfont = f1),
yaxis = list(title = 'Dim2 (16.3%)',
titlefont = f1,
tickfont = f1),
zaxis = list(title = 'Dim3 (13.2%)',
titlefont = f1,
tickfont = f1)),
annotations = list(
x = 1.13,
y = 1.05,
text = 'Annual SOC change rate (‰)',
font=f1,
xref = 'paper',
yref = 'paper',
showarrow = FALSE
))
fig
试试这个
fig <- plot_ly(Interviews, x = ~a, y = ~b, z = ~c,
marker = list(color = ~d,
colorbar=list(tickfont=f1),
colorscale = list(c(0,'red'),
c(0.5,'pink'),
c(1, 'green'))))
或这个
fig <- plot_ly(Interviews, x = ~a, y = ~b, z = ~c,
intensity = ~d,
colorscale = list(c(0,'red'),
c(0.5,'pink'),
c(1, 'green')))
我正在尝试绘制 3D 散点图(前 3 个维度的 PCA 散点图),但我找不到更改 plot_ly 上的颜色条的方法。
代码在下面,这是我得到的,但我希望它从红色(最负值)到绿色(上限值),转折点(淡粉色)为 0 而不是+18‰好像在图上。
你能帮帮我吗?
ind5<-get_pca_ind(PCA_data5)
a<-ind5$coord[,1]
b<-ind5$coord[,2]
c<-ind5$coord[,3]
d<-Interviews$`Annual_SOC_rate_‰`
f1 <- list(
family = "Times New Roman",
size = 20,
color = "black")
fig <- plot_ly(Interviews, x = ~a, y = ~b, z = ~c,
marker = list(color = ~d,
colorbar=list(tickfont=f1),
showscale = TRUE))
fig <- fig %>% add_markers()
fig <- fig %>% layout(scene = list(xaxis = list(title = 'Dim1 (18.8%)',
titlefont = f1,
tickfont = f1),
yaxis = list(title = 'Dim2 (16.3%)',
titlefont = f1,
tickfont = f1),
zaxis = list(title = 'Dim3 (13.2%)',
titlefont = f1,
tickfont = f1)),
annotations = list(
x = 1.13,
y = 1.05,
text = 'Annual SOC change rate (‰)',
font=f1,
xref = 'paper',
yref = 'paper',
showarrow = FALSE
))
fig
试试这个
fig <- plot_ly(Interviews, x = ~a, y = ~b, z = ~c,
marker = list(color = ~d,
colorbar=list(tickfont=f1),
colorscale = list(c(0,'red'),
c(0.5,'pink'),
c(1, 'green'))))
或这个
fig <- plot_ly(Interviews, x = ~a, y = ~b, z = ~c,
intensity = ~d,
colorscale = list(c(0,'red'),
c(0.5,'pink'),
c(1, 'green')))