When faceting with ggplot and plotly the points are plotted in the incorrect facet windows.

57 views
Skip to first unread message

Andrew Wallin

unread,
Jul 12, 2016, 7:37:08 PM7/12/16
to ggplot2

I have a shiny app that plots data that is queried from our company database. You can choose to facet the plot based on different columns in the dataframe. I am using facet_grid and two selectInputs to facet from the side, top or both. I am also building a ggplot object and then using plotly_build to make a plotly plot in shiny. I have tried to solve the problem outside of the shiny app by faceting serialnumber ~ serialnumber.

I am expecting to see the points being plotted in the facet windows diagonal, however it is just plotting in the first column all the way down. Here is the code I amusing to plot. I have changed all of the data because it is sensitive. This is only one example of this it presents in many other phenotypes. Also sorry for the mess of axis labels i was just trying to see if i could solve the problem and not making it look pretty. Let me know if there is anymore information you need?

gg_color_hue <- function(x){
  hues = seq(15,375, length = x+1)
  hcl(h = hues, l = 65, c = 100)[1:x] 
}

ggplot(data= queryData, aes(x = AssayName, y = Metric, colour = SerialNumber)) +
 scale_colour_manual(values = gg_color_hue(length(unique(queryData$SerialNumber))),name = "SerialNumber") +
 facet_grid(SerialNumber ~  SerialNumber) +
 geom_point(size = 2) + 
 theme_set(theme_gray(base_size = 12)) +
 theme(axis.text.x = element_text(angle = 90, hjust = 2)) +
 labs(title = 'all assay') +
 xlab(paste("assays")) + 
 ylab("metric") +
 scale_y_continuous(limits = c(0, 32),
                 breaks = (seq(0,32, by = 5)))
enter image description here



Brandon Hurr

unread,
Jul 12, 2016, 7:39:58 PM7/12/16
to Andrew Wallin, ggplot2
I have had similar issues when having many facets like this. I think Carson should be made aware but I haven't had time to make a good reproducible example for filing a github issue. If you can narrow it down and post a gist or github issue on the ropensci repo that would be super helpful.

Brandon.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages