15
15
# ' in accordance with the computed `theta` position. If `FALSE` (default),
16
16
# ' no such transformation is performed. Can be useful to rotate text geoms in
17
17
# ' 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.
19
19
# '
20
20
# ' @note
21
21
# ' In `coord_radial()`, position guides are can be defined by using
22
22
# ' `guides(r = ..., theta = ..., r.sec = ..., theta.sec = ...)`. Note that
23
23
# ' these guides require `r` and `theta` as available aesthetics. The classic
24
24
# ' `guide_axis()` can be used for the `r` positions and `guide_axis_theta()` can
25
25
# ' be used for the `theta` positions. Using the `theta.sec` position is only
26
- # ' sensible when `donut > 0`.
26
+ # ' sensible when `inner.radius > 0`.
27
27
# '
28
28
# ' @export
29
29
# ' @examples
30
30
# ' # A partial polar plot
31
31
# ' ggplot(mtcars, aes(disp, mpg)) +
32
32
# ' 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)
34
34
coord_radial <- function (theta = " x" ,
35
35
start = 0 , end = NULL ,
36
36
expand = TRUE ,
37
37
direction = 1 ,
38
38
clip = " off" ,
39
39
r_axis_inside = NULL ,
40
40
rotate_angle = FALSE ,
41
- donut = 0 ) {
41
+ inner.radius = 0 ) {
42
42
43
43
theta <- arg_match0(theta , c(" x" , " y" ))
44
44
r <- if (theta == " x" ) " y" else " x"
@@ -47,7 +47,7 @@ coord_radial <- function(theta = "x",
47
47
check_bool(rotate_angle )
48
48
check_number_decimal(start , allow_infinite = FALSE )
49
49
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 )
51
51
52
52
end <- end %|| % (start + 2 * pi )
53
53
if (start > end ) {
@@ -64,7 +64,7 @@ coord_radial <- function(theta = "x",
64
64
direction = sign(direction ),
65
65
r_axis_inside = r_axis_inside ,
66
66
rotate_angle = rotate_angle ,
67
- donut = c(donut , 1 ) * 0.4 ,
67
+ inner_radius = c(inner.radius , 1 ) * 0.4 ,
68
68
clip = clip
69
69
)
70
70
}
@@ -84,13 +84,13 @@ CoordRadial <- ggproto("CoordRadial", Coord,
84
84
distance = function (self , x , y , details ) {
85
85
arc <- details $ arc %|| % c(0 , 2 * pi )
86
86
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 )
88
88
theta <- theta_rescale_no_clip(
89
89
x , details $ theta.range ,
90
90
arc , self $ direction
91
91
)
92
92
} 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 )
94
94
theta <- theta_rescale_no_clip(
95
95
y , details $ theta.range ,
96
96
arc , self $ direction
@@ -117,8 +117,8 @@ CoordRadial <- ggproto("CoordRadial", Coord,
117
117
c(
118
118
view_scales_polar(scale_x , self $ theta , expand = self $ expand ),
119
119
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 )
122
122
)
123
123
},
124
124
@@ -224,7 +224,7 @@ CoordRadial <- ggproto("CoordRadial", Coord,
224
224
bbox <- panel_params $ bbox %|| % list (x = c(0 , 1 ), y = c(0 , 1 ))
225
225
arc <- panel_params $ arc %|| % c(0 , 2 * pi )
226
226
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 )
228
228
data $ theta <- theta_rescale(
229
229
data $ theta , panel_params $ theta.range ,
230
230
arc , self $ direction
@@ -258,7 +258,7 @@ CoordRadial <- ggproto("CoordRadial", Coord,
258
258
bbox <- panel_params $ bbox %|| % list (x = c(0 , 1 ), y = c(0 , 1 ))
259
259
arc <- panel_params $ arc %|| % c(0 , 2 * pi )
260
260
dir <- self $ direction
261
- donut <- panel_params $ donut
261
+ inner_radius <- panel_params $ inner_radius
262
262
263
263
theta_lim <- panel_params $ theta.range
264
264
theta_maj <- panel_params $ theta.major
@@ -273,7 +273,7 @@ CoordRadial <- ggproto("CoordRadial", Coord,
273
273
theta_fine <- seq(self $ arc [1 ], self $ arc [2 ], length.out = 100 )
274
274
275
275
r_fine <- r_rescale(panel_params $ r.major , panel_params $ r.range ,
276
- panel_params $ donut )
276
+ panel_params $ inner_radius )
277
277
278
278
# This gets the proper theme element for theta and r grid lines:
279
279
# panel.grid.major.x or .y
@@ -308,8 +308,8 @@ CoordRadial <- ggproto("CoordRadial", Coord,
308
308
309
309
ggname(" grill" , grobTree(
310
310
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 ),
313
313
element_render(
314
314
theme , majorr , name = " radius" ,
315
315
x = rescale(rep(r_fine , each = length(theta_fine )) *
@@ -453,7 +453,7 @@ view_scales_polar <- function(scale, theta = "x", expand = TRUE) {
453
453
# ' @examples
454
454
# ' polar_bbox(c(0, 1) * pi)
455
455
polar_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 )) {
457
457
458
458
# Early exit if we have full circle or more
459
459
if (abs(diff(arc )) > = 2 * pi ) {
@@ -463,8 +463,8 @@ polar_bbox <- function(arc, margin = c(0.05, 0.05, 0.05, 0.05),
463
463
# X and Y position of the sector arc ends
464
464
xmax <- 0.5 * sin(arc ) + 0.5
465
465
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
468
468
469
469
margin <- c(
470
470
max(ymin ) + margin [1 ],
@@ -546,16 +546,16 @@ flip_data_text_angle <- function(data) {
546
546
}
547
547
548
548
549
- theta_grid <- function (theta , element , donut = c(0 , 0.4 ),
549
+ theta_grid <- function (theta , element , inner_radius = c(0 , 0.4 ),
550
550
bbox = list (x = c(0 , 1 ), y = c(0 , 1 ))) {
551
551
n <- length(theta )
552
552
if (n < 1 ) {
553
553
return (NULL )
554
554
}
555
555
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
559
559
560
560
element_grob(
561
561
element ,
0 commit comments