Bubble Chart in R with # of Occurrences / Sums of Values

前端 未结 2 955
我在风中等你
我在风中等你 2021-01-28 20:31

I\'m playing around with drawing bubble charts in R -- the current project is to graph a bubble chart of political donations that has the following characteristics:



        
2条回答
  •  醉梦人生
    2021-01-28 21:11

    This is easy when you use the ggplot2 package with geom_point.

    One of many benefits of using ggplot is that the built-in statistics means you don't have to pre-summarise your data. geom_point in combination with stat_sum is all you need.

    Here is the example from ?geom_point. (Note that mtcars is a built-in dataset with ggplot2.)

    See the ggplot website and geom_point for more detail.

    library(ggplot2)
    ggplot(mtcars, aes(wt, mpg)) + geom_point(aes(size = qsec))
    

    enter image description here

提交回复
热议问题