Home > OS >  R Plotly - Breaking down a Quantile Plot
R Plotly - Breaking down a Quantile Plot

Time:04-09

I created a plot with multiple boxplots using this code from the singer data (this is reproducible):

library(tidyverse)
library(plotly)
library(lattice)
plot_ly(singer, y = ~height, color = ~voice.part, type = "box")

It created this beautiful box plot that was broken down by the voice part:

enter image description here

Now, the issue I'm having is that I'm trying to do the same thing but with a quantile plot, but no matter what I do, it ends up being all clumped together still, like this:

enter image description here

Oh, and this is the code I used for that:

fvalfull <- (1:nrow(singer) - 0.5) / nrow(singer)
dffull <- tibble(smpl = singer$height, voice.part = singer$voice.part, fval = fvalfull)
plot2 <- ggplot(dffull, aes(sample = smpl))   
  geom_qq(distribution = qunif)
ggplotly(plot2, color = ~dffull$voice.part)

Is there any way I can get all eight of the quantile plots to show up in the same plot? I know I can just make eight separate plots, but I think it would be more interesting to have all of them in the same plot, similar to the box plots.

Thank you!

CodePudding user response:

I am not sure if this is what you want, but I created a quantile plot which shows all the voice.parts in one plot with different colors. You can use the following code:

library(tidyverse)
library(plotly)
library(lattice)
p <- ggplot(dffull, aes(sample=smpl)) 
  geom_qq(distribution = qunif, aes(colour=voice.part))  
  xlim(c(0,1))

ggplotly(p)

Output:

enter image description here

  • Related