0

I'm doing a 3D graph, I did prepare the data to have levels of alerts from 1-5. But not all the measurements have all the alert levels.for example in this graph I don't have level 3 and it should be 1 2 4.

enter image description here

How can I link the alert level to a specific color so I can apply it for all the variables. the following is the code I used:

x <- mile$Locn
y <- mile$Twist3m
z <- mile$TwSeverity
axx <- list(
   title = "Location (mile)"
 )
axy <- list(
   title = "Twist3m"
 )
 axz <- list(
   title = "TwSeverity" , nticks= 5,
   range = c(1,5)
 )
Twfig <- plot_ly(mile, x = ~x,
                 y = ~y, 
                 z = ~TwSeverity,
                 type = 'scatter3d', 
                 mode = 'lines+markers', 
                 color = ~TwSeverity,
                 colors = c("green", "yellow", "coral", "pink", "blue"))%>%
   layout(title = 'Twist3m fault')
Twfig <- Twfig %>% layout(scene = list(xaxis=axx,yaxis=axy,zaxis=axz))
Twfig

Linking each level to a specific color

Kat
  • 15,669
  • 3
  • 18
  • 51
  • Any suggestions please? – Abdulaziz Alotaibi May 20 '23 at 20:51
  • It looks like you're new to SO; welcome to the community! If you want great answers quickly, it's best to make your question reproducible. This includes sample data like the output from `dput()` or `reprex::reprex()` and any libraries you are using. Check it out: [making R reproducible questions](https://stackoverflow.com/q/5963269). **That being said** you can change the call for the argument `colors` to `colors = ~setNames(c("green", "yellow", "coral", "pink", "blue"), unique(TwSeverity))` If that doesn't work for you, try editing your question using the link I provided for guidance. – Kat May 30 '23 at 20:05

0 Answers0