1

I would like to produce what I think will be a very simple diagram in R - it will show the number of genes that fall in to one of two categories.

The area of circles must be relative to each other and show the vast difference between the number of counts in my two categories. One category is 15000 the other is 15. Therefore the area of one circle should be 1000 times greater than the other. Is there a simple R script that can be used to do this? (Draw two circles, one of which there area is X times smaller than the other)

rg255
  • 4,119
  • 3
  • 22
  • 40
  • I usually refer to this kind of graphic as a "bubble plot", although I also see them called "bubble charts". Using either of those search terms in conjunction with R will help you find many more examples of how to make these. [Example](http://flowingdata.com/2010/11/23/how-to-make-bubble-charts/). – aosmith Aug 27 '13 at 17:47

2 Answers2

2

You can draw circles using the plotrix package and draw.circle function. So to answer your question, we just need to calculate the radius of each circle. To make the comparison, it's easier to make the first circle have unit area. So,

## Calculate radius for given area
get_radius = function(area = 1) sqrt(area/pi)

##Load package and draw blank graph
library(plotrix)
plot(-10:10,seq(-10,10,length=21),type="n",xlab="",ylab="")

## Unit area
draw.circle(0, 0, get_radius())

## 10 times larger
draw.circle(0, 0, get_radius(10))
csgillespie
  • 59,189
  • 14
  • 150
  • 185
0

As shown in this post, you can use for example the shape package and use the function plotcircle where you can chose the radius. Example:

require("shape")
emptyplot(c(0, 1))
plotcircle(mid = c(0.2, 0.5), r = 0.1)
plotcircle(mid = c(0.6, 0.5), r = 0.01)

enter image description here

Community
  • 1
  • 1
user1981275
  • 13,002
  • 8
  • 72
  • 101