# How can I make circle plots?

I have not idea how to call these things, but I just saw a paper with the following figure

and I was wondering how one would go about doing it in LaTeX. The closest thing I saw on TeXample.net was the Ford Circles example, but that's for a very specific case. I would like to see a way use this as a plotting device. At this point, I am not even sure how to do it in "normal" programming language, so perhaps the question is ill-placed.

At any rate, I'd love to hear what people think!

• The scaling and colorizing of the small circles is trivial. On the other hand, the positioning of multiple circles of arbitrary sizes so that they don't overlap, and at the same time are compactly arranged within one big container circle is a hard problem. Writing a general algorithm for this may be an interesting exercise in a real programming language; in TeX, I would only attempt it had absolutely nothing else to do, for example if I were serving a life sentence in prison. Oh and I would have to be much younger too. – Michael Palmer Jan 17 '12 at 22:08
• Any idea on what this problem is called? just so I could search for it in other "circles" (ha!) – Yossi Farjoun Jan 17 '12 at 22:12
• @YossiFarjoun: I believe they're called circular treemaps. Not sure they're the best way to communicate data, but they're very pretty =) – Jake Jan 17 '12 at 22:56
• Most treemaps use rectangles instead of circles. If you could use those, there's an R package for doing that. See this blog for a very straightforward tutorial. – Alan Munn Jan 18 '12 at 3:07
• Wikipedia has a decent-looking article on "circle packing" that may be useful. – Michael Palmer Jan 18 '12 at 4:44

As already observed by Michael Palmer your question boils down to a circle packing problem. I am not an expert in the subject but I know at least one person who is. His name is Ken Stephenson from University of Tennessee. Please check out his gallery! He is also providing algorithms and Java based software which can be used to create those magnificent pictures on his webpage.

On the another hand, I am very interested in an alternative solution in the classical sense of Mittag Leffler (power series) of N-body problem which is solved for 3 bodies by Karl Sundman and N>3 by my Ph.D. advisor Qiudong Wang. The solution boils down to a construction of the explicit Riemann mapping which can be done algorithmically via discrete version of Riemann mapping (circle packing). If you would like to look into that problem please contact me via private e-mail and we can try to write a paper together.

Sorry, no TeX answer here and probably even if we attack problem we will not use TeX as a programming language but very interesting problem never the less.

• hmmm. somewhat out of my league. While I am a mathematician, I haven't done this kind of math...sounds interesting, but I don't think I will be able to contribute anything... – Yossi Farjoun Jan 19 '12 at 19:02

I found a java implementation which is a fun way to take a look at your directory structure. It also allows arbitrary .xml files as input, but I didn't see a nice way to save as .png or similar.

The implementation also leaves something to be desired, as this screenshot shows:

(it was genenerated by taking all the files in my home directory, and creating an xml file with one level, and the files' sizes are the size of the circles)

I have no desire to transfer it to LaTeX....though...maybe better to write a python script and input the circle centers and radii into LaTeX.

run with latex->dvips->ps2pdf

\documentclass{minimal}
\usepackage{pst-fractal}
\begin{document}

\begin{pspicture}(-5,-5)(5,5)