I need to make .svg file that contains an array of black circles that all have radii of 5 units ad are evenly spaced apart from each other 32 units.

The difficulty in creating this design is the sheer number of circles necessary. I will need a 3175 by 3175 array. At first I tried doing this manually in Adobe Illustrator, but then it occurred to me that I could write a code to do it for me in Mathematica.

n = 50;
mat = Flatten[Table[{32 i, 32 j}, {i, 0, n - 1, 1}, {j, 0, n - 1, 1}], 1];
g = Disk[#, 5] & /@ mat;
Export["circle_array.svg", Graphics[g], "SVG"];

Above is the code I wrote, and it for a small number of rows/columns, it works just fine. After it's created, I open it up in Adobe Illustrator, and it looks just fine.

However, when I try to increase the number of rows much greater than 100 X 100, after it's exported and I open it up in Adobe Illustrator. I notice that not all the circles are evenly spaced away from each other, and I don't understand why.

If anyone could help, it would be greatly appreciated.

  • 1
    $\begingroup$ Do they look evenly spaced prior to exporting? i.e. does Graphics[g] look OK in Mathematica? $\endgroup$ Jun 5, 2014 at 11:31
  • $\begingroup$ It looks correct for me in PDF: picture here. $\endgroup$
    – Öskå
    Jun 5, 2014 at 12:56
  • $\begingroup$ Can you elaborate on the odd spacing? Perhaps a screenshot would help. Could this be a rendering issue with AI? Oh, and do you want circles or disks? $\endgroup$
    – Yves Klett
    Jun 5, 2014 at 20:58

1 Answer 1


If you use Adobe Illustrator, the most natural format is not SVG, but PDF. This file loads in a fraction of the time which SVG needs and the issue is fixed.

n = 200;
mat = Flatten[Table[{32 i, 32 j}, {i, 0, n - 1, 1}, {j, 0, n - 1, 1}], 1];
g = Disk[#, 5] & /@ mat;
Export["circle_array.pdf", Graphics[g]];

enter image description here

  • $\begingroup$ Thanks for the responses, everyone, but I guess my problems occurred when I continued to increased the dimensions. I ultimately need a 3175X3175 array but the computation time is a big hindrance. I need to submit this file to be printed, and they actually only accept a DXF format. I saw you can create this kind of file with Mathematica, but when I tried to import into Illustrator to view, that was also another problem, as it appeared to be corrupted. My work-around was to create a SVG, import into Illustrator, and then have Illustrator convert to DXF and that's when I noticed the odd spacing. $\endgroup$ Jun 5, 2014 at 20:45
  • $\begingroup$ DXF export does a terrible job with Disk, as it tries to approximate the disk with a number of polygons. This bloats the dxf file and takes about forever. Circle works better, but for your huge number of circles dxf will be a really bad choice. $\endgroup$
    – Yves Klett
    Jun 5, 2014 at 21:22
  • $\begingroup$ @SebastianFreeman OK, it would have been better to state from the beginning what your exact task is. Would it be possible that you join the Mathematica Chat so we can discuss a possible idea I have? (I know you currently don't have enough rep to do so, I hope this changes shortly). $\endgroup$
    – halirutan
    Jun 5, 2014 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.