File: helper-setup.R

package info (click to toggle)
r-cran-patchwork 1.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,624 kB
  • sloc: sh: 15; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 992 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# vdiffr ignores failures when
#   - VDIFFR_RUN_TESTS is "false" (on Travis CI with older versions and dev version of R)
#   - CI is not set (on CRAN)

expect_doppelganger <- vdiffr::expect_doppelganger

# Predefined plots

library(ggplot2)

if (packageVersion("ggplot2") >= "4.0.0") {
  ggplot2::set_theme(ggplot2::theme_test() + ggplot2::theme(panel.grid = ggplot2::element_blank()))
} else {
  ggplot2::theme_set(ggplot2::theme_test() + ggplot2::theme(panel.grid = ggplot2::element_blank()))
}

p1 <- ggplot2::ggplot(mtcars) +
  ggplot2::geom_point(ggplot2::aes(mpg, disp)) +
  ggplot2::ggtitle('Plot 1')

p2 <- ggplot2::ggplot(mtcars) +
  ggplot2::geom_boxplot(ggplot2::aes(gear, disp, group = gear)) +
  ggplot2::ggtitle('Plot 2')

p3 <- ggplot2::ggplot(mtcars) +
  ggplot2::geom_point(ggplot2::aes(hp, wt, colour = mpg)) +
  ggplot2::ggtitle('Plot 3')

p4 <- ggplot2::ggplot(mtcars) +
  ggplot2::geom_bar(ggplot2::aes(gear)) +
  ggplot2::facet_wrap(~cyl) +
  ggplot2::ggtitle('Plot 4')