7
$\begingroup$

I define two graphics for Ebbinghaus illusion

color = RGBColor[0.5686314191548986`, 0.6431257328883857`, 0.7255014941881315`] 
color2 = RGBColor[0.9019616959261525, 0.49803803022437004,0.2235295987167626]

g1 = Graphics[{color2, Disk[{0, 0}, 0.5], color, Disk[{2.1, 0}, 1], 
color, Disk[{2.1 Sin[Pi/6], 2.1 Cos[Pi/6]}, 1], color, 
Disk[{-2.1, 0}, 1], color, 
Disk[{-2.1 Sin[Pi/6], 2.1 Cos[Pi/6]}, 1], color, 
Disk[{2.1 Sin[Pi/6], -2.1  Cos[Pi/6]}, 1], color, 
Disk[{-2.1 Sin[Pi/6], -2.1  Cos[Pi/6]}, 1]}]

and

g2=Graphics[{color2, Disk[{0, 0}, 0.5], color, 
Disk[{ Sin[Pi/4], Cos[Pi/4]}, 0.3], color, 
Disk[{ Sin[2 Pi/4], Cos[(2 Pi)/4]}, 0.3], color, 
Disk[{ Sin[3 Pi/4], Cos[3 Pi/4]}, 0.3], color, 
Disk[{ Sin[4 Pi/4], Cos[4 Pi/4]}, 0.3], color, 
Disk[{ Sin[(5 Pi)/4], Cos[(5 Pi)/4]}, 0.3], color, 
Disk[{ Sin[6 Pi/4], Cos[(6 Pi)/4]}, 0.3], color, 
Disk[{ Sin[7 Pi/4], Cos[(7 Pi)/4]}, 0.3], color, 
Disk[{ Sin[8 Pi/4], Cos[(8 Pi)/4]}, 0.3]}]

how to plot it side by side like the original image

enter image description here

I tried:

GraphicsGrid[g1, g2]

but it doesn't work

$\endgroup$
  • 2
    $\begingroup$ You just have the wrong syntax for Grid, which always takes an array. Try GraphicsRow[{g1, g2}] or GraphicsGrid[{{g1, g2}}]. $\endgroup$ – MarcoB Jun 28 '16 at 19:10
  • $\begingroup$ @MarcoB ok. but size of centered spheres is not same $\endgroup$ – vito Jun 28 '16 at 19:17
  • 2
    $\begingroup$ Use Show[g1, Translate[#, {5, 0}] & /@ g2] to put them side by side. Working only with Graphics is the best way to ensure that the coordinate system is preserved, that no resizing is happening etc. $\endgroup$ – C. E. Jun 28 '16 at 19:24
  • $\begingroup$ @vito just add ImageSize to your g1 and g2 and it should work $\endgroup$ – e.doroskevic Jun 28 '16 at 19:28
  • $\begingroup$ @C.E. thanks. it works :) $\endgroup$ – vito Jun 28 '16 at 19:46
6
$\begingroup$

I would create your graphics illusion with a single Graphics expression; like so

With[
   {color1 = RGBColor[0.569, 0.643, 0.725],
    color2 = RGBColor[0.902, 0.498, 0.224]},
 Module[{group1, group2},
   group1 =
     {color2, Disk[{0, 0}, 0.5],
      color1, Disk[{2.1, 0}, 1],
      Disk[{2.1 Sin[Pi/6], 2.1 Cos[Pi/6]}, 1],
      Disk[{-2.1, 0}, 1],
      Disk[{-2.1 Sin[Pi/6], 2.1 Cos[Pi/6]}, 1],
      Disk[{2.1 Sin[Pi/6], -2.1 Cos[Pi/6]}, 1],
      Disk[{-2.1 Sin[Pi/6], -2.1 Cos[Pi/6]}, 1]};
   group2 =
     {color2, Disk[{0, 0}, 0.5],
      color, Disk[{Sin[Pi/4], Cos[Pi/4]}, 0.3],
      Disk[{Sin[2 Pi/4], Cos[(2 Pi)/4]}, 0.3],
      Disk[{Sin[3 Pi/4], Cos[3 Pi/4]}, 0.3],
      Disk[{Sin[4 Pi/4], Cos[4 Pi/4]}, 0.3],
      Disk[{Sin[(5 Pi)/4], Cos[(5 Pi)/4]}, 0.3],
      Disk[{Sin[6 Pi/4], Cos[(6 Pi)/4]}, 0.3],
      Disk[{Sin[7 Pi/4], Cos[(7 Pi)/4]}, 0.3],
      Disk[{Sin[8 Pi/4], Cos[(8 Pi)/4]}, 0.3]};
   Graphics[{group1, Translate[group2, {5, 0}]}]]]

image

This guarantees that both groups of disks are created in the a single coordinate system.

With Mathematica V10.1 or later this can simplified by using CirclePoints to place the outer ring of circles.

With[
    {color1 = RGBColor[0.569, 0.643, 0.725],
     color2 = RGBColor[0.902, 0.498, 0.224],
     offset = {5, 0},
     r = .5, r1 = 1., r2 = .3, R1 = 2.1, R2 = .9},
  Module[{group1, group2},
    group1 =
     {color2, Disk[{0, 0}, r],
      color1, Disk[#, r1] & /@ CirclePoints[R1, 6]};
    group2 =
      {color2, Disk[offset, r],
       color1, Disk[#, r2] & /@ CirclePoints[offset, {R2, 0}, 8]};
    Graphics[{group1, group2}]]]

image

$\endgroup$
3
$\begingroup$

Example

Code

color = RGBColor[0.5686314191548986`, 0.6431257328883857`, 
  0.7255014941881315`]
color2 = RGBColor[0.9019616959261525, 0.49803803022437004, 
  0.2235295987167626]

g1 = Graphics[{color2, Disk[{0, 0}, 0.5], color, Disk[{2.1, 0}, 1], 
   color, Disk[{2.1 Sin[Pi/6], 2.1 Cos[Pi/6]}, 1], color, 
   Disk[{-2.1, 0}, 1], color, 
   Disk[{-2.1 Sin[Pi/6], 2.1 Cos[Pi/6]}, 1], color, 
   Disk[{2.1 Sin[Pi/6], -2.1 Cos[Pi/6]}, 1], color, 
   Disk[{-2.1 Sin[Pi/6], -2.1 Cos[Pi/6]}, 1]}, ImageSize -> 200]

g2 = Graphics[{color2, Disk[{0, 0}, 0.5], color, 
   Disk[{Sin[Pi/4], Cos[Pi/4]}, 0.3], color, 
   Disk[{Sin[2 Pi/4], Cos[(2 Pi)/4]}, 0.3], color, 
   Disk[{Sin[3 Pi/4], Cos[3 Pi/4]}, 0.3], color, 
   Disk[{Sin[4 Pi/4], Cos[4 Pi/4]}, 0.3], color, 
   Disk[{Sin[(5 Pi)/4], Cos[(5 Pi)/4]}, 0.3], color, 
   Disk[{Sin[6 Pi/4], Cos[(6 Pi)/4]}, 0.3], color, 
   Disk[{Sin[7 Pi/4], Cos[(7 Pi)/4]}, 0.3], color, 
   Disk[{Sin[8 Pi/4], Cos[(8 Pi)/4]}, 0.3]}, ImageSize -> 100]

GraphicsRow[{g1,g2}]

Output

output

Reference

GraphicsRow
ImageSize

$\endgroup$
  • 2
    $\begingroup$ Worth to mention CirclePoints for V10+. $\endgroup$ – Kuba Jun 28 '16 at 19:41
  • $\begingroup$ @E.Doroskevic why exactly ImageSize->100 and not ImageSize->101 ? :) centered spheres is not same size in your graphic $\endgroup$ – vito Jun 28 '16 at 19:49
  • $\begingroup$ @vito I just used arbitrary numbers, feel free to manipulate these as you find appropriate $\endgroup$ – e.doroskevic Jun 28 '16 at 19:50
2
$\begingroup$

I used code from C.E comment, and it works perfectly!

color = RGBColor[0.5686314191548986`, 0.6431257328883857`,0.7255014941881315`]
color2 = RGBColor[0.9019616959261525, 0.49803803022437004,0.2235295987167626]

g1 = Graphics[{color2, Disk[{0, 0}, 0.5], color, Disk[{2.1, 0}, 1], 
color, Disk[{2.1 Sin[Pi/6], 2.1 Cos[Pi/6]}, 1], color, 
Disk[{-2.1, 0}, 1], color, 
Disk[{-2.1 Sin[Pi/6], 2.1 Cos[Pi/6]}, 1], color, 
Disk[{2.1 Sin[Pi/6], -2.1 Cos[Pi/6]}, 1], color, 
Disk[{-2.1 Sin[Pi/6], -2.1 Cos[Pi/6]}, 1]}]

g2 = Graphics[{color2, Disk[{0, 0}, 0.5], color, 
Disk[{Sin[Pi/4], Cos[Pi/4]}, 0.3], color, 
Disk[{Sin[2 Pi/4], Cos[(2 Pi)/4]}, 0.3], color, 
Disk[{Sin[3 Pi/4], Cos[3 Pi/4]}, 0.3], color, 
Disk[{Sin[4 Pi/4], Cos[4 Pi/4]}, 0.3], color, 
Disk[{Sin[(5 Pi)/4], Cos[(5 Pi)/4]}, 0.3], color, 
Disk[{Sin[6 Pi/4], Cos[(6 Pi)/4]}, 0.3], color, 
Disk[{Sin[7 Pi/4], Cos[(7 Pi)/4]}, 0.3], color, 
Disk[{Sin[8 Pi/4], Cos[(8 Pi)/4]}, 0.3]}]

Show[g1, Translate[#, {5, 0}] & /@ g2]

enter image description here

$\endgroup$

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