R 基于度量的散点图颜色

R 基于度量的散点图颜色,r,plotly,R,Plotly,我正在使用散点图,我想将公制CYI更改为绿色,公制LYI更改为红色 library(plotly) dataset <- data.frame(SC = c("A","B","C","D"), CYI = c(100,150,180,80), LYI = c(80,120,190,90) ) CYI_Text <- paste("Status Category = ", dataset$SC,

我正在使用散点图,我想将公制CYI更改为绿色,公制LYI更改为红色

library(plotly)
dataset <- data.frame(SC = c("A","B","C","D"),
                      CYI =  c(100,150,180,80),
                      LYI = c(80,120,190,90)
)

CYI_Text <- paste("Status Category = ", dataset$SC, "<br>",
                  "Current Year Interaction = ", dataset$CYI, "<br>")
LYI_Text <- paste("Status Category = ", dataset$SC, "<br>",
                  "Last Year Interaction = ", dataset$LYI, "<br>")

g <- plot_ly(dataset, x = dataset$SC, y = dataset$CYI, mode = 'markers' , marker = list(size =20) ) %>%
  add_trace(x= dataset$SC, y = dataset$CYI , type = 'scatter', hoverinfo = "text", text = CYI_Text, color ="red", showlegend = FALSE) %>%
  add_trace(x= dataset$SC, y = dataset$LYI , type = 'scatter', hoverinfo = "text", text = LYI_Text, color ="green", showlegend = TRUE)
g
library(plotly)
数据集%
添加跟踪(x=数据集$SC,y=数据集$LYI,类型='scatter',hoverinfo=“text”,text=LYI\u text,color=“green”,showlegend=TRUE)
G

非常感谢您的帮助。

wrap
color='red'
in
marker=list(color='red')
非常感谢您的快速回复。