1515# ' in accordance with the computed `theta` position. If `FALSE` (default),
1616# ' no such transformation is performed. Can be useful to rotate text geoms in
1717# ' alignment with the coordinates.
18- # ' @param donut A `numeric` between 0 and 1 setting the size of a donut hole.
18+ # ' @param inner.radius A `numeric` between 0 and 1 setting the size of a inner.radius hole.
1919# '
2020# ' @note
2121# ' In `coord_radial()`, position guides are can be defined by using
2222# ' `guides(r = ..., theta = ..., r.sec = ..., theta.sec = ...)`. Note that
2323# ' these guides require `r` and `theta` as available aesthetics. The classic
2424# ' `guide_axis()` can be used for the `r` positions and `guide_axis_theta()` can
2525# ' be used for the `theta` positions. Using the `theta.sec` position is only
26- # ' sensible when `donut > 0`.
26+ # ' sensible when `inner.radius > 0`.
2727# '
2828# ' @export
2929# ' @examples
3030# ' # A partial polar plot
3131# ' ggplot(mtcars, aes(disp, mpg)) +
3232# ' geom_point() +
33- # ' coord_radial(start = -0.4 * pi, end = 0.4 * pi, donut = 0.3)
33+ # ' coord_radial(start = -0.4 * pi, end = 0.4 * pi, inner.radius = 0.3)
3434coord_radial <- function (theta = " x" ,
3535 start = 0 , end = NULL ,
3636 expand = TRUE ,
3737 direction = 1 ,
3838 clip = " off" ,
3939 r_axis_inside = NULL ,
4040 rotate_angle = FALSE ,
41- donut = 0 ) {
41+ inner.radius = 0 ) {
4242
4343 theta <- arg_match0(theta , c(" x" , " y" ))
4444 r <- if (theta == " x" ) " y" else " x"
@@ -47,7 +47,7 @@ coord_radial <- function(theta = "x",
4747 check_bool(rotate_angle )
4848 check_number_decimal(start , allow_infinite = FALSE )
4949 check_number_decimal(end , allow_infinite = FALSE , allow_null = TRUE )
50- check_number_decimal(donut , min = 0 , max = 1 , allow_infinite = FALSE )
50+ check_number_decimal(inner.radius , min = 0 , max = 1 , allow_infinite = FALSE )
5151
5252 end <- end %|| % (start + 2 * pi )
5353 if (start > end ) {
@@ -64,7 +64,7 @@ coord_radial <- function(theta = "x",
6464 direction = sign(direction ),
6565 r_axis_inside = r_axis_inside ,
6666 rotate_angle = rotate_angle ,
67- donut = c(donut , 1 ) * 0.4 ,
67+ inner_radius = c(inner.radius , 1 ) * 0.4 ,
6868 clip = clip
6969 )
7070}
@@ -84,13 +84,13 @@ CoordRadial <- ggproto("CoordRadial", Coord,
8484 distance = function (self , x , y , details ) {
8585 arc <- details $ arc %|| % c(0 , 2 * pi )
8686 if (self $ theta == " x" ) {
87- r <- rescale(y , from = details $ r.range , to = self $ donut / 0.4 )
87+ r <- rescale(y , from = details $ r.range , to = self $ inner_radius / 0.4 )
8888 theta <- theta_rescale_no_clip(
8989 x , details $ theta.range ,
9090 arc , self $ direction
9191 )
9292 } else {
93- r <- rescale(x , from = details $ r.range , to = self $ donut / 0.4 )
93+ r <- rescale(x , from = details $ r.range , to = self $ inner_radius / 0.4 )
9494 theta <- theta_rescale_no_clip(
9595 y , details $ theta.range ,
9696 arc , self $ direction
@@ -117,8 +117,8 @@ CoordRadial <- ggproto("CoordRadial", Coord,
117117 c(
118118 view_scales_polar(scale_x , self $ theta , expand = self $ expand ),
119119 view_scales_polar(scale_y , self $ theta , expand = self $ expand ),
120- list (bbox = polar_bbox(self $ arc , donut = self $ donut ),
121- arc = self $ arc , donut = self $ donut )
120+ list (bbox = polar_bbox(self $ arc , inner_radius = self $ inner_radius ),
121+ arc = self $ arc , inner_radius = self $ inner_radius )
122122 )
123123 },
124124
@@ -224,7 +224,7 @@ CoordRadial <- ggproto("CoordRadial", Coord,
224224 bbox <- panel_params $ bbox %|| % list (x = c(0 , 1 ), y = c(0 , 1 ))
225225 arc <- panel_params $ arc %|| % c(0 , 2 * pi )
226226
227- data $ r <- r_rescale(data $ r , panel_params $ r.range , panel_params $ donut )
227+ data $ r <- r_rescale(data $ r , panel_params $ r.range , panel_params $ inner_radius )
228228 data $ theta <- theta_rescale(
229229 data $ theta , panel_params $ theta.range ,
230230 arc , self $ direction
@@ -258,7 +258,7 @@ CoordRadial <- ggproto("CoordRadial", Coord,
258258 bbox <- panel_params $ bbox %|| % list (x = c(0 , 1 ), y = c(0 , 1 ))
259259 arc <- panel_params $ arc %|| % c(0 , 2 * pi )
260260 dir <- self $ direction
261- donut <- panel_params $ donut
261+ inner_radius <- panel_params $ inner_radius
262262
263263 theta_lim <- panel_params $ theta.range
264264 theta_maj <- panel_params $ theta.major
@@ -273,7 +273,7 @@ CoordRadial <- ggproto("CoordRadial", Coord,
273273 theta_fine <- seq(self $ arc [1 ], self $ arc [2 ], length.out = 100 )
274274
275275 r_fine <- r_rescale(panel_params $ r.major , panel_params $ r.range ,
276- panel_params $ donut )
276+ panel_params $ inner_radius )
277277
278278 # This gets the proper theme element for theta and r grid lines:
279279 # panel.grid.major.x or .y
@@ -308,8 +308,8 @@ CoordRadial <- ggproto("CoordRadial", Coord,
308308
309309 ggname(" grill" , grobTree(
310310 background ,
311- theta_grid(theta_maj , grid_elems [[1 ]], donut , bbox ),
312- theta_grid(theta_min , grid_elems [[2 ]], donut , bbox ),
311+ theta_grid(theta_maj , grid_elems [[1 ]], inner_radius , bbox ),
312+ theta_grid(theta_min , grid_elems [[2 ]], inner_radius , bbox ),
313313 element_render(
314314 theme , majorr , name = " radius" ,
315315 x = rescale(rep(r_fine , each = length(theta_fine )) *
@@ -453,7 +453,7 @@ view_scales_polar <- function(scale, theta = "x", expand = TRUE) {
453453# ' @examples
454454# ' polar_bbox(c(0, 1) * pi)
455455polar_bbox <- function (arc , margin = c(0.05 , 0.05 , 0.05 , 0.05 ),
456- donut = c(0 , 0.4 )) {
456+ inner_radius = c(0 , 0.4 )) {
457457
458458 # Early exit if we have full circle or more
459459 if (abs(diff(arc )) > = 2 * pi ) {
@@ -463,8 +463,8 @@ polar_bbox <- function(arc, margin = c(0.05, 0.05, 0.05, 0.05),
463463 # X and Y position of the sector arc ends
464464 xmax <- 0.5 * sin(arc ) + 0.5
465465 ymax <- 0.5 * cos(arc ) + 0.5
466- xmin <- donut [1 ] * sin(arc ) + 0.5
467- ymin <- donut [1 ] * cos(arc ) + 0.5
466+ xmin <- inner_radius [1 ] * sin(arc ) + 0.5
467+ ymin <- inner_radius [1 ] * cos(arc ) + 0.5
468468
469469 margin <- c(
470470 max(ymin ) + margin [1 ],
@@ -546,16 +546,16 @@ flip_data_text_angle <- function(data) {
546546}
547547
548548
549- theta_grid <- function (theta , element , donut = c(0 , 0.4 ),
549+ theta_grid <- function (theta , element , inner_radius = c(0 , 0.4 ),
550550 bbox = list (x = c(0 , 1 ), y = c(0 , 1 ))) {
551551 n <- length(theta )
552552 if (n < 1 ) {
553553 return (NULL )
554554 }
555555
556- donut <- rep(donut , n )
557- x <- rep(sin(theta ), each = 2 ) * donut + 0.5
558- y <- rep(cos(theta ), each = 2 ) * donut + 0.5
556+ inner_radius <- rep(inner_radius , n )
557+ x <- rep(sin(theta ), each = 2 ) * inner_radius + 0.5
558+ y <- rep(cos(theta ), each = 2 ) * inner_radius + 0.5
559559
560560 element_grob(
561561 element ,
0 commit comments