Eracog
Eracog

Reputation: 225

Creating bubble charts with ggplot2

I have the following results which I would like to translate to a bubble graph:

Data for bubbles:

stockA = 0.39 (38/99)
stockB = 0.18 (18/99) 
stockC = 0.68 (68/99)
For y axes frequency scale from 0 - 70

and for x axes until 99

The numbers of y axes is the numerator of fraction and the x axes is the denominator of fraction.

How is it possible to make a plot like this one enter image description here Are these data enough to make this plot?

data points for x and y axes and size for bubble

x,y,size of bubble
126, 54, 5.3
57, 60, 9.1
57, 43, 0.5
424, 53, 11.5
62, 44, 5.0
30, 32, 1.4
28, 33, 4.9

Upvotes: 0

Views: 570

Answers (1)

Matias Andina
Matias Andina

Reputation: 4220

You were almost there. I named your data.frame "a" (next time use dput for easier import to R)

a
    x  y size
1 126 54  5.3
2  57 60  9.1
3  57 43  0.5
4 424 53 11.5
5  62 44  5.0
6  30 32  1.4
7  28 33  4.9 

ggplot(a,aes(x,y))+geom_point(size=a$size)

Produces

enter image description here

Of course, ggplot will let you play with all the layers as usual. Also, you might want to check the Google package for making bubble charts googleVis. But ggplot2 is good enough for many reasons. Just add more columns if you want more customization.

Upvotes: 1

Related Questions