Cartesianxy2Polarxy: Transform the x, y positions from a Cartesian coordinate to a...

View source: R/Cartesianxy2Polarxy.R

Cartesianxy2PolarxyR Documentation

Transform the x, y positions from a Cartesian coordinate to a polar coordinate

Description

Used in the 'loonLayer' construction to access the x, y positions embedded in the polar coordinate system.

Usage

Cartesianxy2Polarxy(layerGeom, coordinates, data, ggplotPanelParams, ...)

Arguments

layerGeom

A ggplot layer object

coordinates

A ggplot object coordinate system

data

the data used for the transformation

ggplotPanelParams

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

Examples

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)

loon.ggplot documentation built on Nov. 13, 2022, 1:06 a.m.