| rectxy {plothelper} | R Documentation | 
Generating Coordinates of Multiple Rectangles
Description
Note: the shapes are correct  
only when ggplot2::coord_fixed() is used.
Usage
rectxy(
  x = 0,
  y = 0,
  a = 1,
  b = 1,
  angle = 0,
  xytype = "middle",
  group = TRUE,
  todf = TRUE,
  checks = TRUE
)
Arguments
x | 
 the x coordinates of relative points. 
Its length can be larger than 1.
See   | 
y | 
 the y coordinates of relative points. 
Its length can be larger than 1.
See   | 
a | 
 the side that is parallel to x-axis before rotation. Its length can be larger than 1.  | 
b | 
 the side that is parallel to y-axis before rotation. Its length can be larger than 1.  | 
angle | 
 default is 0. The rotation angle in radian. Note: "radian = degree * pi / 180". Its length can be larger than 1. The rotation direction is anti-clockwise.  | 
xytype | 
 should be one of "middle/center" (default), "bottomleft", "middleleft/centerleft/left". It indicates the type of argument of the middle point of an shape. If it is "middleleft", x and y are the middle-left coordinates before rotation. If it is "bottomleft", x and y are the coordinates of the bottom-left corner.  | 
group | 
 default is TRUE. It indicates 
whether to add a 3rd column named 
"g" to label the group number of each group of points. It is useful 
when using   | 
todf | 
 default is TRUE. It indicates whether to combine the output (a list) into a data frame.  | 
checks | 
 default is TRUE. It indicates whether to check input validity. Do not turn it off unless you are sure that the input is OK.  | 
Value
if todf = TRUE, the output will be a data frame
with coordinates of possibly several polygons, otherwise, 
it will be a list of data frames. Data frames have 2 columns
named "x" and "y", and if group = TRUE, a third column 
named "g" is added indicating group numbers.
Examples
library(ggplot2)
dat1=rectxy(x=4, y=3, a=2, b=1, angle=0, xytype="bottomleft", todf=TRUE) 
dat2=rectxy(x=4, y=3, a=2, b=1, angle=pi/6, xytype="bottomleft", todf=TRUE)
ggplot()+
	geom_polygon(data=dat1, aes(x=x, y=y), fill="red", alpha=0.3)+
	geom_polygon(data=dat2, aes(x=x, y=y), fill="blue", alpha=0.3)+	
	coord_fixed()