I am trying to overlap two Graphics
objects g1
and g2
with Show
. However, I found that when the coordinates of each object is defined to quite different ranges, I need to "scale" and "shift" the coordinates of one object to get the desired look.
For example,
g1 = Graphics[{GrayLevel[0.8], Rectangle[{-2, -2}, {2, 2}]}];
g2 = Graphics[{{GrayLevel[0.5], Rectangle[{0, 0}, {1, 1}]}}];
Show[g1, AspectRatio -> 1, Axes -> True, ImageSize -> 230]
Show[g2, AspectRatio -> 1, Axes -> True, ImageSize -> 230]
Show[g1, g2, AspectRatio -> 1, Axes -> True, ImageSize -> 230]
The overlapped version of g1
and g2
looks like this
However, I would like to scale the coordinates of g2
to make g2
twice large and also shift its coordinates so the center can "roughly" coincide the center of g1
. I say "roughly" because g1
and g2
may be some graphics not of a regular shape. The desired result will look like
So how can I manipulate the coordinates of g2
to adjust its relative position and size when Show
with g1
? Please avoid modifying the definition of g1
and g2
as they can be any Graphics
copy-pasted over.