I have three different datasets that representing data for different year, they all have same y-axis and x-axis? For example like the plot shown below except this is in R and it is dotplot
Asked
Active
Viewed 444 times
0
-
1aHI, please try to make your questions *reproducible*. This includes sample code (including listing non-base R packages) and sample *unambiguous* data (e.g., `dput(head(x))` or `data.frame(x=...,y=...)`). Refs: https://stackoverflow.com/questions/5963269, https://stackoverflow.com/help/mcve, and https://stackoverflow.com/tags/r/info. (Two points from this: (1) make it easy for us to help you by not making us create data unnecesarily; (2) show some effort on your part.) – r2evans Jun 05 '19 at 23:37
-
... but in general, most (if not all) `ggplot2` geoms allow the "group" aesthetic (including `geom_dotplot`, as I said in my other comment), which will allow something like this. Alternatively, you can use one of the `facet_*` functions to produce facets of data, though that is not exactly what you've demonstrated here. – r2evans Jun 05 '19 at 23:38
1 Answers
0
One approach to combining graphs for display is create them separately with ggplot and combine them with patchwork.
library(ggplot2)
install.packages("devtools")
devtools::install_github("thomasp85/patchwork")
library(patchwork)
p1 <- ggplot(mtcars, aes(x = mpg)) + geom_dotplot()
p2 <- ggplot(mtcars, aes(x = hp)) + geom_dotplot()
p3 <- ggplot(mtcars, aes(x = wt)) + geom_dotplot()
p1 + p2 + p3
#or
ggplot(mtcars) +
geom_dotplot(aes(mpg)) +
ggplot(mtcars) +
geom_dotplot(aes(hp)) +
ggplot(mtcars) +
geom_dotplot(aes(wt))
Also cowplot::plot_grid
https://cran.r-project.org/web/packages/cowplot/vignettes/plot_grid.html

Tony Ladson
- 3,539
- 1
- 23
- 30