Closed lcougnaud closed 5 years ago
This works now with the development version of cowplot. I hope to release relatively soon.
library(ggplot2)
library(cowplot)
#>
#>
#> *******************************************************
#> Note: cowplot does not change the default ggplot2 theme
#> anymore. To recover the previous behavior, execute:
#> theme_set(theme_cowplot())
#> *******************************************************
data(iris)
plot1 <- ggplot(data = iris) + geom_point(aes(x = `Sepal.Length`, y = `Sepal.Width`)) +
facet_grid(Species~., switch = "y") + theme(strip.placement = "outside")
plot2 <- ggplot(data = iris) + geom_point(aes(x = `Petal.Length`, y = `Petal.Width`, col = "Species"))
plot_grid(plot1, plot2, ncol = 1, align = "v", axis = "lr")
Created on 2019-05-11 by the reprex package (v0.2.1)
I experienced an issue when aligning two ggplot2 plots: one facetted plot and one without facetted. The two plots are not properly aligned:
I narrowed down the issue to the use of the strip placement, placed outside of the plot. If the placement remains inside the plot, the plots are properly aligned according to the x-axis:
The issue seems fixed when the 'complex alignments' (
vcomplex_align
,hcomplex_align
set to TRUE) are used within thealign_plots
function.Session information: R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS
locale: LC_ADDRESS=en_GB.UTF-8, LC_COLLATE=en_US.UTF-8, LC_CTYPE=en_US.UTF-8, LC_IDENTIFICATION=en_GB.UTF-8, LC_MEASUREMENT=en_GB.UTF-8, LC_MESSAGES=en_US.UTF-8, LC_MONETARY=en_GB.UTF-8, LC_NAME=en_GB.UTF-8, LC_NUMERIC=C, LC_PAPER=en_GB.UTF-8, LC_TELEPHONE=en_GB.UTF-8, LC_TIME=en_GB.UTF-8
attached base packages: base, datasets, graphics, grDevices, methods, stats, utils
other attached packages: cowplot_0.9.3, ggplot2_3.0.0, oaReporting_0.0.6, reprex_0.2.0, rj_2.1.0-13, xtable_1.8-3
loaded via a namespace (and not attached): assertthat_0.2.0, backports_1.1.2, bindr_0.1.1, bindrcpp_0.2.2, callr_2.0.4, clipr_0.4.1, colorspace_1.3-2, crayon_1.3.4, debugme_1.1.0, devtools_1.13.5, digest_0.6.15, dplyr_0.7.5, evaluate_0.10.1, glue_1.2.0, grid_3.3.3, gtable_0.2.0, htmltools_0.3.6, knitr_1.20, labeling_0.3, lazyeval_0.2.1, magrittr_1.5, memoise_1.1.0, munsell_0.5.0, pillar_1.2.1, pkgconfig_2.0.1, plyr_1.8.4, processx_3.1.0, purrr_0.2.5, R6_2.2.2, Rcpp_0.12.18, reshape2_1.4.3, rj.gd_2.1.0-2, rlang_0.2.1.9000, rmarkdown_1.10, rprojroot_1.3-2, scales_1.0.0.9000, stringi_1.2.3, stringr_1.3.1, tibble_1.4.2, tidyselect_0.2.4, tools_3.3.3, whisker_0.3-2, withr_2.1.2