4
$\begingroup$

I'm trying to draw two graphics object well defined and an arrow in between pointing left to right (symbolizing the mapping between the two). I've tried drawing the arrow first in a graphics object and then using GraphicsRow but the end result is unsatisfying: I get that the arrow takes a third of the space, when I would like it much smaller. How could I get there?

$\endgroup$
  • $\begingroup$ Select the graphics, Right-click, "Drawing Tools" $\endgroup$ – Dr. belisarius Dec 5 '14 at 14:58
  • $\begingroup$ @belisarius: I did it this way in the past, but I would be interested in a systematic way of doing it. $\endgroup$ – Learning is a mess Dec 5 '14 at 15:06
  • $\begingroup$ Then check out this. It's a nice mix of both, I believe $\endgroup$ – Dr. belisarius Dec 5 '14 at 15:24
3
$\begingroup$
gF = Graphics[{#[[1]], #[[2]], Black, 
     Text[Style["\[RightArrow]", 72, Bold], Scaled@{.5, 1/2}],
     #2[[1]], Translate[#2[[2]], {3., 0}]}, ImageSize -> 500] &;

gF[{Blue, Disk[]}, {Red, Polygon[{{1, -1}, {0, Sqrt[3] - 1}, {-1, -1}}]}]

enter image description here

gF[{Blue, Polygon[Table[{Cos[2 \[Pi] k/6], Sin[2 \[Pi] k/6]}, {k, 0,  5}]]},
   {Red,  Polygon[Table[{Cos[2 \[Pi] k/9], Sin[2 \[Pi] k/9]}, {k, 0, 8}]]}]

enter image description here

Or

g1 = Graphics[{Blue, Disk[{0, 0}, 1]}, BaselinePosition -> Center, ImageSize -> 300];
g2 = Graphics[{Red, Polygon[{{4, -1}, {3, Sqrt[3] - 1}, {2, -1}}]}, 
   BaselinePosition -> Center, ImageSize -> 300];
g3 = Graphics[{Orange, Polygon[Table[{Cos[2 \[Pi] k/9], Sin[2 \[Pi] k/9]}, {k, 0, 8}]]}, 
   BaselinePosition -> Center, ImageSize -> 300];
g4 = Graphics[Text@Style["\[RightArrow]", 64, Bold], BaselinePosition -> Center, ImageSize -> 50];

Row[{g1, g2, g3}, g4]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks you, it works like a charm indeed! $\endgroup$ – Learning is a mess Dec 5 '14 at 19:45
  • $\begingroup$ @Learningisamess, my pleasure. Thank you for the accept. $\endgroup$ – kglr Dec 5 '14 at 19:52
3
$\begingroup$

Try this:

 Manipulate[Show[{
   Graphics[{Blue, Disk[{0, 0}, 1]}],
   Graphics[{Red, Polygon[{{4, -1}, {3, Sqrt[3] - 1}, {2, -1}}]}],
   Graphics[{Darker@Green, Thickness[0.007], 
     Arrow[{{x1, y1}, {x2, y1}}]}]

   }], {{x1, 1}, 0, 3}, {{y1, 0.1}, 0, 3}, {{x2, 2.5}, 0, 3}]

and play with the sliders. You should see the following:

enter image description here

Have fun!

$\endgroup$
1
$\begingroup$

In practice, the output form of Rule is effective for combinations of graphics and other expressions. For example, see:

  • My answer to Temporal database reconstruction (note existing rules in Association and Dataset)

  • Try kguler's graphics with g1 -> g2 -> g3

  • Can be used to quikly make legends for figures from Associations. Given data = <| "a" -> Red, "b" -> Blue|>, data // Normal // Column // Panel gives:

enter image description here

Limitations include:

  • The result is not a Graphics object (though often it renders to PDF just fine).

  • No control over the arrow's style (or is there?)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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