fadingPrimitive[size_, formula_, c_] :=
  Max[0, formula],
  {x, -size, size}, {y, -size, size},
  ColorFunction -> (Opacity[#, c] &),
  Frame -> False];

smoothlyFadingColorDisk[r_, c_] :=
 fadingPrimitive[r, r - Sqrt[x^2 + y^2], c];

smoothlyFadingColorRing[rs_, rb_, c_] :=
 fadingPrimitive[rs + rb, rs - Abs[rb - Sqrt[x^2 + y^2]], c];

Up to this point everything works nice. The image size is exactly as large as the actual graphics:

smoothlyFadingColorDisk[1, Purple]

enter image description here

smoothlyFadingColorRing[0.25, 1.25, Blue]

enter image description here

But when I try to combine them, the image size suddenly gets much larger than the actual graphics:

 Inset[smoothlyFadingColorDisk[1, Purple]],
 Inset[smoothlyFadingColorRing[0.25, 1.25, Blue]]}]

enter image description here

I tried ImageSize->Scaled[1], ImageSize->Full, ImageSize->All, ImageSize->Automatic - all fail or even make the disproportion even greater.

 smoothlyFadingColorRing[0.25, 1.25, Blue],
 smoothlyFadingColorDisk[1, Purple]]

This works as expected, but I'd rather avoid show: I want to be able to use Insets to be able to reposition the graphics, and it seems I can't use Insets with Show.

Why does this happen? How to set this straight? Thanks in advance!

  • 1
    $\begingroup$ closely related: 73522 $\endgroup$
    – Kuba
    Feb 12, 2015 at 9:11

1 Answer 1


The coordinate system of the enclosing Graphics is completely independent of the one used in the Inset. So you have to specify in Inset how it is to be positioned and sized relative to the enclosing Graphics. In your case, you just want to modify the size. That's the fourth argument in Inset (it's optional), so the code looks like this:

Graphics[{Inset[smoothlyFadingColorDisk[1, Purple], Automatic, 
   Automatic, Scaled[1]], 
  Inset[smoothlyFadingColorRing[0.25, 1.25, Blue], Automatic, 
   Automatic, Scaled[1]]}]



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.