Skip to content

Compare two ggplots to check whether they are equal

Usage

# S3 method for ggplot
gradethis_equal(x, y, ...)

Arguments

x, y

Two ggplot objects to compare

...

Unused

Value

A logical value of length one, or an internal gradethis error.

See also

gradethis::gradethis_equal() for the generic function.

Examples

library(ggplot2)
library(ggcheck)
library(gradethis)

cty_plot <- ggplot(mpg, aes(x = displ, y = cty)) + geom_point()
hwy_plot <- ggplot(mpg, aes(x = displ, y = cty)) + geom_point()

gradethis_equal(cty_plot, hwy_plot)
#> [1] FALSE
gradethis_equal(cty_plot, cty_plot)
#> [1] TRUE