R/Cartesianxy2Polarxy.R
Cartesianxy2Polarxy.Rd
Used in the `loonLayer` construction to access the x, y positions embedded in the polar coordinate system.
Cartesianxy2Polarxy(layerGeom, coordinates, data, ggplotPanelParams, ...)
A ggplot
layer object
A ggplot
object coordinate system
the data used for the transformation
some non-data panel parameters,
i.e. the range of theta, the range of radius, theta major, theta minor, etc. It is obtained from the
ggplot_build(p)$layout$panel_params
where "p" is a ggplot
object
for further use
p <- ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
coord_polar()
layerGeom <- p$layers[[1L]]$geom
coordinates <- p$coordinates
build <- ggplot_build(p)
data <- build$data[[1L]]
ggplotPanelParams <- build$layout$panel_params[[1L]]
polarXY <- Cartesianxy2Polarxy(layerGeom, coordinates, data, ggplotPanelParams)
plot(polarXY$x, polarXY$y)