coord_rect {gggda} | R Documentation |
Cartesian coordinates and plotting window with fixed aspect ratios
Description
Geometric data analysis often requires that coordinates lie on
the same scale. The coordinate system CoordRect
, alias CoordSquare
,
provides control of both coordinate and window aspect ratios.
Usage
coord_rect(
ratio = 1,
window_ratio = ratio,
xlim = NULL,
ylim = NULL,
expand = TRUE,
clip = "on"
)
Arguments
ratio |
aspect ratio, expressed as |
window_ratio |
aspect ratio of plotting window |
xlim , ylim |
Limits for the x and y axes. |
expand |
If |
clip |
Should drawing be clipped to the extent of the plot panel? A
setting of |
Value
A Coord
ggproto object.
Examples
# ensures that the resolutions of the axes and the dimensions of the plotting
# window respect the specified aspect ratios
p <- ggplot(mtcars, aes(mpg, hp/10)) + geom_point()
p + coord_rect(ratio = 1)
p + coord_rect(ratio = 1, window_ratio = 2)
p + coord_rect(ratio = 1, window_ratio = 1/2)
p + coord_rect(ratio = 5)
p + coord_rect(ratio = 1/5)
p + coord_rect(xlim = c(15, 30))
p + coord_rect(ylim = c(15, 30))
# square (even excluding some geometric constructions)
p + coord_square(xlim = c(0, 30), ylim = c(20, 40))