I have a doughnut sort of plot which i plot using the ggplot2. Code was shared by @Jonspring.
data.frame(
stringsAsFactors = FALSE,
Tenure.Type = c("Tenure_A","Tenure_B",
"Tenure_C","Tenure_D","Tenure_E"),
In.Poverty = c(45786L, 98453L, 34954L, 29586L, 74854L),
Not.in.Poverty = c(784733L, 359584L, 385884L, 948434L, 385869L)
) -> Poverty
library(tidyverse)
Poverty %>%
pivot_longer(-Tenure.Type) %>%
uncount(round(value/1000)) %>%
ggplot(aes(1, name, color = Tenure.Type))
geom_jitter()
coord_polar()
This is what i got -
I was wondering if there is any way to increase the size/surface area of the outer ring while keeping the inner ring as it is. Thanks.
I tried using the agruments inside the Coord_polar() but I can't get it to work.
Note - If you can notice, in the plot each dot represents 1000 observations. So, is there something in which we can achieve like each outer ring's dot represents 10,000 observations and each inner ring's dot represent 1,000 observations? Thanks.
CodePudding user response:
You can split those 2 categories between separate jitter layers and play around with jitter heights to achieve something like this:
library(tidyverse)
Poverty %>%
pivot_longer(-Tenure.Type) %>%
uncount(round(value/1000)) %>%
ggplot(aes(1, name, color = Tenure.Type, shape = name))
geom_jitter(data = ~filter(.x, name == "Not.in.Poverty" ), height = .6)
geom_jitter(data = ~filter(.x, name == "In.Poverty" ), height = .35)
scale_shape_manual(
name = "Scale",
values = c("Not.in.Poverty" = 15, "In.Poverty" = 19),
labels = c("Not.in.Poverty" = "n=10000", "In.Poverty" = "n=1000")
)
coord_polar()
Input data:
Poverty <- data.frame(
stringsAsFactors = FALSE,
Tenure.Type = c("Tenure_A","Tenure_B",
"Tenure_C","Tenure_D","Tenure_E"),
In.Poverty = c(45786L, 98453L, 34954L, 29586L, 74854L),
Not.in.Poverty = c(784733L, 359584L, 385884L, 948434L, 385869L)
)
Created on 2023-01-31 with reprex v2.0.2