# Combine of a square and a parallelogram with GraphicsRow

g1 = Graphics[{EdgeForm[{Thick, Blue}], FaceForm[], Rectangle[]},
ImageSize -> {400, 400}];

g2 = Graphics[{{EdgeForm[{Dashed, Blue}], FaceForm[], Rectangle[]},
GeometricTransformation[{EdgeForm[{Thick, Blue}], FaceForm[],
Rectangle[]}, ShearingMatrix[30 Degree, {1, 0}, {0, 1}]]},
ImageSize -> {400, 400}];


But when I use GraphicsRow or Grid the two graphs appear with different sizing:

GraphicsRow[{g1, g2}]

Grid[{g1, g2}]


I guess this is trivial but I cannot find a way so that the two graphs appear with the same size.

PS. Actually I want to replicate in Mathematica the following figure starting from scratch.

• do you get what you need if you add the option AspectRatio -> 1 to g1 and g2?
– kglr
Dec 22, 2018 at 1:23
• @kglr No. The squate appears as a rectangle now. Dec 22, 2018 at 1:29
• @kglr I tried to clarify my question. See the edit. Dec 22, 2018 at 1:34

Update:

ClearAll[arrowAxes, annotatedArrow]
arrowAxes[lbl_, lngth_: 1/2, asize_: Large, off_: {20, -15}] :=
{Arrowheads[asize], Arrow[{{0, 0}, {0, lngth}}], Arrow[{{0, 0}, {lngth, 0}}],
Text[lbl[[1]], Offset[off, {0, lngth}]],
Text[lbl[[2]], Offset[Reverse[off], {lngth, 0}]]}

annotatedArrow[lbls_, fromto_: {{0, 0}, {0, 1}}, size_: .025] :=
Module[{ends = Graphics[{AbsoluteThickness[1/5],
Line[{{-1, 1/2}, {0, 0}, {-1, -1/2}}], Line[{{0, 1}, {0, -1}}]}],
labels = Graphics[{Text[Framed[#, FrameStyle -> None, Background -> White],
{0, 0}, Center]}] & /@ lbls},
## & @@ Thread[{size, Subdivide[1 + Length@lbls][[2 ;; -2]], labels}],
{size, 1, ends}}], Arrow[fromto]}]


Examples:

isa = {300, 300};
isb = ShearingTransform[30 Degree, {1, 0}, {0, 1}][isa];
pnt = ShearingTransform[30 Degree, {1, 0}, {0, 1}][{0, 1}];
ga = Graphics[{EdgeForm[{Thick, Blue}], FaceForm[], Rectangle[],
arrowAxes[Style[Subscript[e, #], 18, Bold] & /@ {1, 2}]},
ImageSize -> isa, ImagePadding -> 25];
gb = Graphics[{{EdgeForm[{Dashed, Blue}], FaceForm[], Rectangle[]},
GeometricTransformation[{EdgeForm[{Thick, Blue}], FaceForm[],
Rectangle[]}, ShearingMatrix[30 Degree, {1, 0}, {0, 1}]],
arrowAxes[Style[Subscript[e, #], 18, Bold] & /@ {1, 2}],
Gray, AbsoluteThickness[1/5],
annotatedArrow[{Style[h, 18, Italic]}, Offset[{-20, 0}, #] & /@ {{0, 0}, {0, 1}}],
annotatedArrow[{Style[γ h, 18, Italic]}, Offset[{0, 20}, #] & /@ {{0, pnt[[2]]}, pnt}]},
ImageSize -> isb, ImagePadding -> 25];

GraphicsRow[{ga, gb}, Spacings -> {0, 0}]


Grid[{{ga, gb}}]


Use ShearingTransform[30 Degree, {1, 0}, {0, 1}][{400, 400}] as the image size for g2 and add the option PlotRangePadding -> None to g1 and g2:

g1 = Graphics[{EdgeForm[{Thick, Blue}], FaceForm[], Rectangle[]},
ImageSize -> {400, 400}, PlotRangePadding -> None];
g2 = Graphics[{{EdgeForm[{Dashed, Blue}], FaceForm[], Rectangle[]},
GeometricTransformation[{EdgeForm[{Thick, Blue}], FaceForm[],
Rectangle[]}, ShearingMatrix[30 Degree, {1, 0}, {0, 1}]]},
ImageSize -> ShearingTransform[30 Degree, {1, 0}, {0, 1}][{400, 400}],

GraphicsRow[{g1, g2}, Spacings -> {0, 0}]


Grid[{{g1, g2}}]


• Thanks. Not so trivial I think:-)! Dec 22, 2018 at 1:47
• @dimitris, you are welcome. Not trivial at all:)
– kglr
Dec 22, 2018 at 1:56
• Can you suggest me ways to include in the figures the annotated arrow, the unit vectors (arrows) and the texts or should I open a new thread? Dec 22, 2018 at 2:07
• @dimitris, thank you for the accept. I think unit vectors would not be difficult (I will post an update). I don't know an easy way to find the correct image size for g2 when texts are added.
– kglr
Dec 22, 2018 at 13:57
• Thanks again for your time! Dec 23, 2018 at 0:58