Home > Mobile >  How to add axis to balloonplot
How to add axis to balloonplot

Time:10-04

I have the following plot

library(ggpubr)
dframe <- as.data.frame(Titanic)
head(dframe)
ggballoonplot(
  dframe, x = "Class", y = "Sex",
  size = "Freq", fill = "Freq",
  facet.by = c("Survived", "Age"),
  ggtheme = theme_bw()
)

enter image description here

enter image description here I was wondering how to add a global x axis - for example "Survival rate"? and "Gender" to the y axis (as presented in the "sketch" of the lower figure

CodePudding user response:

This plot is pretty easy to make just using the regular ggplot2. I've never used ggballoonplot, so I'm not sure if you have a specific use case in mind.

library(tidyverse)


dframe <- as.data.frame(Titanic)

dframe |>
  ggplot(aes(Class, Sex)) 
  geom_point(aes(size = Freq, fill = Freq), pch = 21) 
  facet_grid(Survived~Age) 
  theme_bw() 
  labs(x = "Survival Rate",
       y = "Gender")

  • Related