I am creating a shiny app which displays a volcano plot created with ggplot. For added user interactivity, I started experimenting with plotly. The original ggplot is provided by another package, so I use ggplotly
to convert this plot to plotly
. This works, however, I noticed that plotly changes boolean values (TRUE, FALSE) to numerical values (1, 0) in the plot's legend.
What must I do for plotly to display the boolean values in the legend as ggplot does?
The research I've done thus far only covers the style of the legend, but I have not yet found the answer to this particular question.
Minimal example
With the following data set, plot b
in the x-axis and -log10(qval)
in the y-axis, and color by significant
.
target_id qval b significant
1 AT2G33830.2 1.703189e-167 2.256506e+00 TRUE
2 AT2G35810.2 4.202545e-107 -1.667441e+00 TRUE
3 AT2G23820.1 1.413239e-59 -6.503380e+00 TRUE
4 AT2G33830.1 1.269998e-48 2.124706e+00 TRUE
5 AT2G25964.1 2.555293e-32 -1.152527e+00 TRUE
6 AT2G26740.1 1.106960e-30 3.234900e+00 TRUE
28246 AT1G65040.6 9.998811e-01 5.752283e-05 FALSE
28247 AT1G73430.2 9.998811e-01 8.065345e-05 FALSE
28248 AT2G47020.3 9.998811e-01 7.621082e-05 FALSE
28249 AT3G62840.1 9.998811e-01 1.335211e-05 FALSE
28250 AT5G23090.3 9.998811e-01 1.447117e-04 FALSE
28251 AT5G03830.2 NA -1.856909e-01 NA
R code:
p <- ggplot(sample, aes(b, -log10(qval)))
p <- p + geom_point(aes(colour = significant))
p
displays