uses_coordinate_system: Does a plot use the correct coordinate system?

View source: R/coordinates.R

uses_coordinate_systemR Documentation

Does a plot use the correct coordinate system?

Description

uses_coordinate_system checks whether a plot uses the coordinate system you describe. To describe a coordinate system, use the character string that matches the suffix of the ggplot2 coord_ function that would make the coordinate system. The default coordinate system for ggplot2 plots is "cartesian".

Usage

uses_coordinate_system(p, coordinates)

Arguments

p

A ggplot2 object

coordinates

A character string that corresponds to the suffix of a ggplot2 coord_ function, e.g. "cartesian".

Value

TRUE or FALSE

See Also

Other functions for checking coordinate systems: get_coordinate_system()

Examples

require(ggplot2)
p <- ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
  geom_point(mapping = aes(color = class)) +
  geom_smooth() +
  coord_polar()
uses_coordinate_system(p, coordinates = "polar")

rstudio-education/ggcheck documentation built on May 12, 2023, 11:33 a.m.