0

I have data that looks like this:

Input data

After running the following code:

axx <- list(
  nticks = 3,
  tickvals = c(0,1,2),
  ticktext = c("AA", "Aa", "aa"),
  title = "SNP2 Genotype")

axy <- list(
  nticks = 3,
  tickvals = c(0,1,2),
  ticktext = c("AA", "Aa", "aa"),
  title = "SNP3 Genotype")

axz <- list(
  nticks = 7,
  tickvals = c(0,1,2,3,4,5,6),
  ticktext = c("1", "2", "3", "4", "5", "6"),
  title = "BMI with Tail")

plot_ly(Add3W_T, x = ~SNP2, y = ~SNP3, z = ~phenotype, type = 'scatter3d', mode = 'lines', opacity = 1, color = ~Geno_color,
        line = list(width = 14, color = ~Geno_color, showspikes=FALSE)) %>% 
  layout(scene = list(xaxis = axx, yaxis = axy, zaxis = axz), 
         title = list(text = "3D Reaction Norms - Additive"), 
         legend = list(title = list(text = "SNP1 Genotype")))

I get this resulting image: 3D Scatter plot

I want the legend in the top right to match the colors of the lines set by the first column of my dataframe (Geno_color) but have the text from the last column (SNP1_Geno)

Melderon
  • 365
  • 1
  • 16
  • 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). A _picture_ of your data is not useful. – Kat Dec 10 '22 at 01:24

0 Answers0