xy_to_cartesian | R Documentation |
Transform between coordinate systems
xy_to_cartesian(x, y, track_index = current_track_index())
xy_to_polar(x, y, track_index = current_track_index(), flip = TRUE)
polar_to_cartesian(theta, r)
cartesian_to_polar(x, y)
cartesian_to_xy(x, y, track_index = current_track_index())
x |
X-locations of the data points. |
y |
Y-locations of the data points. |
track_index |
Index of the track. |
flip |
If it is |
theta |
Angles, in radians. |
r |
Radius. |
There are three coordinate systems: the data coordinate system (xy), the polar coordinate system (polar) and the canvas coordinate system (cartesian). The canvas coordinates correspond to the "native" coordinates of the viewport where the graphics are drawn.
Note different settings of flip
and reverse
in spiral_initialize()
affect the conversion.
xy_to_cartesian()
converts from the data coordinate system to the canvas coordinate system.
xy_to_polar()
converts from the data coordinate system to the polar coordinate system.
polar_to_cartesian()
converts from the polar coordinate system to the canvas coordinate system.
cartesian_to_polar()
converts from the canvas coordinate system to the polar coordinate system.
cartesian_to_xy()
converts from the canvas coordinate system to the data coordinate system.
The data points are assigned to the nearest inner spiral loops (if the point is located inside a certain spiral loop, the distance is zero).
xy_to_cartesian()
returns A data frame with two columns: x
and y
.
xy_to_polar()
returns a data frame with two columns: theta
(in radians) and r
(the radius).
polar_to_cartesian()
returns a data frame with two columns: x
and y
.
cartesian_to_polar()
returns a data frame with two columns: theta
(in radians) and r
(the radius).
cartesian_to_xy()
returns a data frame with two columns: x
and y
.
x = runif(2)
y = runif(2)
spiral_initialize(xlim = c(0, 1))
spiral_track(ylim = c(0, 1))
spiral_points(x, y)
xy_to_cartesian(x, y)
xy_to_polar(x, y)
x = runif(100, -4, 4)
y = runif(100, -4, 4)
spiral_initialize(xlim = c(0, 1))
spiral_track(ylim = c(0, 1))
df = cartesian_to_xy(x, y)
# directly draw in the viewport
grid.points(x, y, default.units = "native")
# check whether the converted xy are correct (should overlap to the previous points)
spiral_points(df$x, df$y, pch = 16, gp = gpar(col = 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.