I have a script like this:
colori_BPS <- c("#1289d7", "#00008b")
colori_BPS <- setNames(colori_BPS, levels(dataframe_Brewer_alternativo_3$tipo_BPS))
colori_O3Brewer <- c("#ff0000", "#ffa500")
colori_O3Brewer <- setNames(colori_BPS, levels(dataframe_Brewer_alternativo_3$tipo_O3Brewer))
O3_Brewer_BPS_periodi_plot_2 <- plot_ly(data = dataframe_Brewer_alternativo_3,
x = ~Date,
y = ~O3_BPS,
color = ~tipo_BPS,
colors = colori_BPS,
type = "scatter",
mode="markers",
marker=list(size = 5
),
#name ="BPS ('Good')",
hoverinfo = "text",
text = paste("Date = ", dataframe_Brewer_alternativo_3$Date, "O3_BPS(DU) = ", dataframe_Brewer_alternativo_3$O3_BPS)
)
O3_Brewer_BPS_periodi_plot_2 <- add_trace(O3_Brewer_BPS_periodi_plot_2,
x = ~Date,
y = ~O3,
type = "scatter",
color = ~tipo_O3Brewer,
colors = colori_O3Brewer,
mode = "markers",
marker = list(size = 4
),
#name ="BPS ('Anomalous')",
hoverinfo = "text",
text = paste("Date = ", dataframe_Brewer_alternativo_3$Date, "O3_Brewer(DU) = ", dataframe_Brewer_alternativo_3$O3)
)
for both the traces I used the mode “color” and “colors” to costumize the colors of the sub-traces but when I call the plot it doesn’t work and it gives me this warning:
In colScale(as.character(color[[i]])) :
Some values were outside the color scale and will be treated as NA
if I comment the lines with the “colors” command the plot is done but the software chooses the colors.
Is there any way to costumize the colors of the sub-traces?
thanks.