3
$\begingroup$

I'm trying to join two graphics (defel and masterel) into one figure, but they are superposing each other. How can i do that? Here is the code that generates the two graphics:

 topol = {{1, 2, 3, 4}}
eltype = 2;
forcing = 0.;
nnodes = {{-1, -1}, {1, -1}, {1, 1}, {-1, 1}}
meshVis1 = 
  Graphics[{Arrow[{{0, 0}, {0, 1.5}}], Arrow[{{0, 0}, {1.5, 0}}], 
    FaceForm[], EdgeForm[Black], 
    GraphicsComplex[nnodes, Polygon[topol[[All, {1, 2, 3, 4}]]]]}];
dists1 = Graphics[{Arrow[{{0, -1.1}, {1/Sqrt[3], -1.1}}], 
    Arrow[{{0, -1.1}, {-(1/Sqrt[3]), -1.1}}], 
    Arrow[{{1/Sqrt[3], -1.1}, {0, -1.1}}], 
    Arrow[{{-(1/Sqrt[3]), -1.1}, {0, -1.1}}], FaceForm[], 
    EdgeForm[Black]}];
dists2 = Graphics[{Arrow[{{-1.1, 0}, {-1.1, 1/Sqrt[3]}}], 
    Arrow[{{-1.1, 0}, {-1.1, -(1/Sqrt[3])}}], 
    Arrow[{{-1.1, 1/Sqrt[3]}, {-1.1, 0}}], 
    Arrow[{{-1.1, -(1/Sqrt[3])}, {-1.1, 0}}]}, FaceForm[], 
   EdgeForm[Black]];
nodeVis = Graphics[{Black, PointSize[Medium], Point[nnodes]}];
pts = {{-(1/Sqrt[3]), -(1/Sqrt[3])}, {1/Sqrt[3], -(1/Sqrt[3])}, {1/
    Sqrt[3], 1/Sqrt[3]}, {-(1/Sqrt[3]), 1/Sqrt[3]}};
ptstext = 
  Graphics[{Style[Text["0.57735", {-0.57735/2, -1.2}], Medium], 
    Style[Text["0.57735", {0.57735/2, -1.2}], Medium], 
    Style[Text["0.57735", {-1.2, 0.57735/2}, Automatic, {0, 1}], 
     Medium], 
    Style[Text["0.57735", {-1.2, -0.57735/2}, Automatic, {0, 1}], 
     Medium]}];
integartionpoints = Graphics[{Black, PointSize[Large], Point[pts]}];
axes = Graphics[{Style[Text["\[Xi]", {1.4, -0.2}], Medium], 
    Style[Text["\[Eta]", {0.2, 1.4}], Medium]}];
coords = Graphics[{Style[Text["(-1,-1)", {-1.1, -1.1}], Medium], 
    Style[Text["(1,-1)", {1.1, -1.1}], Medium], 
    Style[Text["(1,1)", {1.1, 1.1}], Medium], 
    Style[Text["(-1,1)", {-1.1, 1.1}], Medium]}];
masterel = 
 Show[meshVis1, nodeVis, axes, coords, integartionpoints, dists1, 
  dists2, ptstext]
(*Export["C:\\Users\\diogo\\Dropbox\\ArtigoFemMathematica\\figuras\\\
masterel.jpg",masterel,ImageResolution\[Rule]300]*)

topol = {{1, 2, 3, 4}}
eltype = 2;
forcing = 0.;
nnodes = {{2, 1}, {5, 2}, {4, 6}, {1, 4}};
meshVis2 = 
  Graphics[{Arrow[{{0.6, 0.5}, {6, 0.5}}], 
    Arrow[{{0.6, 0.5}, {0.6, 6}}], FaceForm[], EdgeForm[Black], 
    GraphicsComplex[nnodes, Polygon[topol[[All, {1, 2, 3, 4}]]]]}];
nodeVis2 = Graphics[{Black, PointSize[Medium], Point[nnodes]}];
axes2 = Graphics[{Style[Text["x", {5.8, 0.25}], Medium], 
    Style[Text["y", {0.4, 5.8}], Medium]}];
coords2 = 
  Graphics[{Style[Text["(2,1)", {1.8, 0.8}], Medium], 
    Style[Text["(5,2)", {5.3, 1.8}], Medium], 
    Style[Text["(4,6)", {4.3, 6.2}], Medium], 
    Style[Text["(1,4)", {0.9, 4.2}], Medium]}];
defel = Show[meshVis2, nodeVis2, axes2, coords2]
Show[masterel, defel]

enter image description here

It should look like this:

enter image description here

$\endgroup$

closed as off-topic by MarcoB, corey979, Feyre, gpap, yohbs Jan 26 '17 at 15:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, corey979, Feyre, gpap, yohbs
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ Can you sketch how the output is supposed to look like? $\endgroup$ – Felix Jan 25 '17 at 18:22
  • $\begingroup$ @Felix i have edited the question including a skech. $\endgroup$ – Diogo Jan 25 '17 at 18:56
  • 3
    $\begingroup$ Instead of Show, use GraphicsRow[{defel, masterel}, ImageSize -> Large]; it generates this figure. $\endgroup$ – MarcoB Jan 25 '17 at 19:16
  • $\begingroup$ Is this question solved by @MarcoB 's comment? $\endgroup$ – Felix Jan 25 '17 at 22:29
  • $\begingroup$ @MarcoB thank you. Do you know how to draw te curved arrow linking the two figures? $\endgroup$ – Diogo Jan 25 '17 at 22:29
7
$\begingroup$

The problem is that you are not joining two Graphics expressions; you are trying to join too many Graphics expressions. The solution is to work with one Graphics expression, which is actually quite easy to do.

I will build up the two main components of your final image from more elementary elements just as you did. I will also build each of the main components in its own coordinate space as you did. I will make the final image by translating and scaling the first the main component.

First component

topol = {{1, 2, 3, 4}};
eltype = 2;
nnodes1 = {{-1, -1}, {1, -1}, {1, 1}, {-1, 1}};
pts = 
  {{-(1/Sqrt[3]), -(1/Sqrt[3])}, {1/Sqrt[3], -(1/Sqrt[3])}, 
   {1/Sqrt[3], 1/Sqrt[3]}, {-(1/Sqrt[3]), 1/Sqrt[3]}};

meshVis1 =
  {Arrowheads[.01],
   Arrow[{{0, 0}, {0, 1.5}}],
   Arrow[{{0, 0}, {1.5, 0}}],
   FaceForm[], EdgeForm[Black],
   GraphicsComplex[nnodes1, Polygon[topol[[All, {1, 2, 3, 4}]]]]};

dists1 =
  {Arrowheads[.01],
   Arrow[{{0, -1.1}, {1/Sqrt[3], -1.1}}], 
   Arrow[{{0, -1.1}, {-(1/Sqrt[3]), -1.1}}], 
   Arrow[{{1/Sqrt[3], -1.1}, {0, -1.1}}], 
   Arrow[{{-(1/Sqrt[3]), -1.1}, {0, -1.1}}]};

dists2 =
  {Arrowheads[.01],
   Arrow[{{-1.1, 0}, {-1.1, 1/Sqrt[3]}}], 
   Arrow[{{-1.1, 0}, {-1.1, -(1/Sqrt[3])}}], 
   Arrow[{{-1.1, 1/Sqrt[3]}, {-1.1, 0}}], 
   Arrow[{{-1.1, -(1/Sqrt[3])}, {-1.1, 0}}]};

nodeVis = {PointSize[Medium], Point[nnodes1]};

ptstext =
  {Text["0.57735", {-0.57735/2, -1.2}],
   Text["0.57735", {0.57735/2, -1.2}],
   Text["0.57735", {-1.2, 0.57735/2}, Automatic, {0, 1}],
   Text["0.57735", {-1.2, -0.57735/2}, Automatic, {0, 1}]};

integartionpoints = {PointSize[Large], Point[pts]};

axeslbls = {Text["ξ", {1.4, -0.2}], Text["η", {0.2, 1.4}]};

coordlbls =
  {Text["(-1, -1)", {-1.1, -1.1}], Text["(1, -1)", {1.1, -1.1}],
   Text["(1, 1)", {1.1, 1.1}], Text["(-1, 1)", {-1.1, 1.1}]};

Second component

topol = {{1, 2, 3, 4}};
eltype = 2;
nnodes2 = {{2, 1}, {5, 2}, {4, 6}, {1, 4}};

meshVis2 =
  {Arrow[{{0.6, 0.5}, {6, 0.5}}],
   Arrow[{{0.6, 0.5}, {0.6, 6}}], FaceForm[], EdgeForm[Black], 
   GraphicsComplex[nnodes2, Polygon[topol[[All, {1, 2, 3, 4}]]]]};

nodeVis2 = {PointSize[Medium], Point[nnodes]};

axeslbls2 = {Text["x", {5.8, 0.25}], Text["y", {0.4, 5.8}]};

coordlbls2 =
  {Text["(2, 1)", {1.8, 0.8}], Text["(5, 2)", {5.3, 1.8}], 
   Text["(4, 6)", {4.3, 6.2}], Text["(1, 4)", {0.9, 4.2}]};

Now all I have to do is translate and scale the first component and add a curved arrow.

Graphics[
  {Scale[
     Translate[
       {meshVis1, nodeVis, axeslbls, coordlbls, integartionpoints, 
        dists1, dists2, ptstext}, 
       {11, 4}], 
     2],
   {Arrowheads[.025], Arrow[BezierCurve[{{5.5, 5}, {6.5, 5.3}, {7.5, 5}}]]},
   {meshVis2, nodeVis2, axeslbls2, coordlbls2}},
  ImageSize -> 500]

diagram

$\endgroup$

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