I made a lollipop graph but the space between them is uneven. It is fine to some extent but need a bit of aesthetics. I tried to fix several times but haven't got the graph that I want.
# Create data
data <- data.frame(
x=LETTERS[1:24],
a=sample(1:30,24),
b=sample(1:40,24),
c=sample(1:50,24),
d=sample(1:20,24,replace=T),
gp=c("Gp A","Gp B","Gp C","Gp D")
)
fig1 <-data %>%
arrange(a) %>%
mutate(x=factor(x, x)) %>%
ggplot(aes(x=x,y=a))+
labs(title = "Child")+
geom_segment( aes(x=x, xend=x, y=0, yend=a), color="grey") +
geom_point( aes(x=x, y=a, color=gp), size=5 ) +
coord_flip()+
theme_ipsum() +
geom_text(aes(label=a),color = "black", size = 2.5)+
theme(
legend.position = "top",
panel.grid.major = element_line(colour = "transparent"),
panel.grid.minor = element_line(colour = "transparent"),
panel.spacing = unit(0.5, "lines"),
axis.text.y = element_text(color='black', size=8),
strip.text.x = element_text(size = 10)
) +
xlab("") +
ylab("Number of articles") +
facet_grid(gp~.,scale="free_y", space = "free_y")
I repeat the same codes for fig(b), fig3(c) and fig4(d). Then I combined all four graph using the following code:
ggarrange(fig1,fig2, fig3,fig4,
labels = c("A", "B", "C","D"),
ncol = 2, nrow = 2)
But the combined plots look a bit packed and not see clearly.
I would like to removed "Gp A" "Gp B" "Gp C" "Gp D" from each plot.
I'm trying to make the plot like below. I have tried several times but still haven't got it. It would be great and really appreciated if someone could kindly share codes how to do it like below graph.