Search code examples
rplotscatterpo

How do I achieve a bubbleplot?


How would I go about achieving a bubble plot like this on R?


Solution

  • To achieve this you could use ggplot. Here an example:

    require(ggplot2)
    
    df <- data.frame(x = c(-2, -1.5, 1, 2, 3),
                   y = c(-1, 0.8, 1, 1, 2),
                   country = c("SWI", "FRA", "US", "UK", "NL"), size = c(15,12,20,4,7))
    
    
    ggplot(df, aes(x = x, y = y)) + geom_point(aes(size = size), pch=1) +geom_text(aes(label=country),hjust=-0.5, vjust=0) + xlim(c(-3,4)) + scale_size_continuous(range = c(2,20))
    

    enter image description here