0

Is there an easy way to avoid overlap of bubbles when working with symbols ?

Here is a minimal example:

set.seed(123)
n = 200
x = runif(n)
size = abs(rnorm(n))
symbols(x,circles=size)

Any suggestions would be greatly appreciated.

ed82
  • 3,007
  • 3
  • 15
  • 11
  • 1
    Size matters. Use `symbols(x,circles=size, inches=0.1)` – Andrie Jan 23 '13 at 15:20
  • @Andrie: indeed the size matters. The issue is that I would like to keep the same circles (same size) as in my example. I would like to only have change in the distance between circles on the x axis. I am not sure it is possible. – ed82 Jan 23 '13 at 15:29
  • 1
    I think you are looking for circle packing: http://en.wikipedia.org/wiki/Circle_packing Your own wrinkle on the problem is that you want to restrict circles to only move along the x axis. Googling for "circle packing" may help you. I think this is not really an R question, you may want to flag it for migration to the Computer Science Stack Exchange, or even somewhere else. – Stephan Kolassa Jan 23 '13 at 17:00
  • 1
    What does the distance between circles represent? Ditto for the size of the circles? If all you want is a bunch of circles plotted with their centers (?) along a line, then adjust the `size[j]` values based on the `x[j]` separations or vice versa. – Carl Witthoft Jan 23 '13 at 19:11

1 Answers1

0

You can stretch the x axis, but you will have to stretch it a lot to eliminate the overlaps:

> png(filename="circles.png", width=5000, height=1000)
> symbols(x, circles=size, xlim=c(0, 200), cex.lab=3, cex.axis=3)
> dev.off()

The png file will be 5000 pixels across by 1000 pixels high and it eliminates most of the overlaps, but not all of them.

dcarlson
  • 10,936
  • 2
  • 15
  • 18