YuLab-SMU / scatterpie

:art: scatter pie plot
https://cran.r-project.org/package=scatterpie
60 stars 16 forks source link

color of outline can be mapped #47

Closed xiangpin closed 5 months ago

xiangpin commented 5 months ago
> 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

> head(d3)
           x          y letters     value Cell r_size
1 -0.2587278 -0.5486010       A 0.5809584    A   0.02
2 -0.7469574  0.2471864       A 0.7770539    A   0.03
3  0.4275919  0.1282868       A 0.8052695    B   0.04
4 -1.5439724  0.6223713       A 0.5662144    C   0.05
5 -2.7569273  0.2987277       A 0.4293619    B   0.06
6 -0.2587278 -0.5486010       B 2.6691236    A   0.02

> p3 <- ggplot() +
       geom_scatterpie(data = d3, mapping = aes(x=x, y=y, r = r_size, color=Cell), cols="letters",
                       long_format=T, donut_radius=.5, color = NA, linewidth=2,
                        bg_circle_radius=1.2) + coord_fixed()

> p3

image