Closed xiangpin closed 3 months ago
label_radius
label_show_ratio
TRUE
label_threshold
> library(ggplot2) > library(scatterpie) > d <- data.frame(x=rnorm(5), y=rnorm(5)) > d$A <- abs(rnorm(5, sd=1)) > d$B <- abs(rnorm(5, sd=2)) > d$C <- abs(rnorm(5, sd=3)) > ggplot() + geom_scatterpie( aes(x=x, y=y), data = d, cols=c("A", "B", "C"), label_radius=1.05 ) + coord_fixed()
> d <- tidyr::gather(d, key="letters", value="value", -x:-y) > d |> dplyr::select(c(x, y)) |> dplyr::distinct() |> dplyr::mutate(Cell=c('A','A','B','C','B')) -> d2 > d |> dplyr::left_join(d2) -> d3 Joining with `by = join_by(x, y)` > d3$r_size <- c(2, 3, 4, 5, 6) * .01 > p4 <- ggplot() + geom_scatterpie(data = d3, mapping = aes(x, y = y, r = r_size), cols = 'letters', long_format = TRUE, label_radius = 1.1, label_show_ratio = FALSE, label_threshold = 0.06, fontsize = 3 ) + coord_fixed() > p4
label_radius
控制标签的位置,相对饼图的半径label_show_ratio
控制标签是比例,还是原始值,默认为TRUE
是比例.label_threshold
为了防止一些较小比例值出现重叠,引入该参数,如果比例小于该值,则不展示