3
$\begingroup$

How to have a reflected mirrored red line at a distance of -1 in the negative y-axis.

gr = Plot[E^x, {x, -3, 2}];
Show[gr, gr /. 
  L_Line :> {Red, 
    GeometricTransformation[L, ReflectionTransform[{0, -1}]]}, 
 PlotRange -> All, ImageSize -> 200]

For this I tried the sugesstion given by kglr, seem like not working.

ansys = {0., 0.000509954, 0.00101645, 0.00151604, 0.00200526, 
   0.00248066, 0.00293881, 0.00337627, 0.0037896, 0.0041754, 
   0.00453024, 0.00485074, 0.0051335, 0.00537516, 0.00557235, 
   0.00572173, 0.00581998, 0.00586378, 0.00584984, 0.00577486, 
   0.0056356, 0.00542879, 0.0051512, 0.00479963, 0.00437085, 
   0.00386167, 0.00326893, 0.00258945, 0.00182007, 
   0.000957637, -9.93932*10^-7, -0.00139589, -0.00294291, \
-0.00462996, -0.00644498, -0.00837593, -0.0104108, -0.0125378, \
-0.0147448, -0.0170203, -0.0193526, -0.02173, -0.0241413, -0.0265752, \
-0.0290206, -0.0314667, -0.0339028, -0.0363186, -0.0387038, \
-0.0410485, -0.0433431, -0.0455783, -0.047745, -0.0498347, \
-0.0518389, -0.0537497, -0.0555596, -0.0572613, -0.058848, \
-0.0603135, -0.0616517, -0.0628571, -0.0639248, -0.0648501, \
-0.065629, -0.0662577, -0.0667332, -0.0670527, -0.0672141, \
-0.0672157, -0.0670562, -0.066735, -0.0662518, -0.0656069, \
-0.0648011, -0.0638355, -0.062712, -0.0614326, -0.0599999, \
-0.0584172, -0.0566879, -0.0548159, -0.0528056, -0.0506618, \
-0.0483896, -0.0459946, -0.0434826, -0.0408598, -0.0381328, \
-0.0353083, -0.0323936, -0.0293959, -0.0263229, -0.0231824, \
-0.0199824, -0.0167311, -0.0134368, -0.010108, -0.00675311, \
-0.0033809, 0.};
ansys = ansys/Max[Abs[ansys]];
X = Subdivide[0, 4, 100];
data2 = Transpose[{X, -ansys}];
p1 = ListPlot[data2, Joined -> False, 
   PlotMarkers -> {Graphics[{Circle[]}, ImageSize -> 25]}, 
   PlotStyle -> {Black}, AxesStyle -> Black, PlotRange -> All];
d = 3;
Show[p1, p1 /. 
  L_Line :> {Red, 
    GeometricTransformation[L, 
     Composition[TranslationTransform[{0, -d}], 
      ReflectionTransform[{0, -1}]]]}, PlotRange -> All, 
 GridLines -> {None, {-d}}]
$\endgroup$

2 Answers 2

4
$\begingroup$

You can also compose TranslationTransform and ReflectionTransform:

d = -3;
tr = Composition[TranslationTransform[{0, d}], ReflectionTransform[{0, -1}]];

Show[gr, gr /. L_Line :> {Red, GeometricTransformation[L, tr]},
   PlotRange -> All, GridLines -> {None, {d}}]

enter image description here

Alternatively, you can use the two argument form of ReflectionTransform

tr2 = ReflectionTransform[{0, -1}, {0, d/2}]

as in Ulrich's answer or AffineTransform:

tr3 = AffineTransform[{{{1, 0}, {0, -1}}, {0, d}}]

to get the same result.

Update: For the new example in OP, since plot markers are rendered using GeometricTransformation we need to apply the transformations to the second argument of objects with head GeometricTransformation:

 Show[p1, p1 /. GeometricTransformation[i_, t_] :> 
     GeometricTransformation[i /. c_Circle :> {Red, c}, tr @ t], 
   PlotRange -> All, GridLines -> {None, {d}}]

enter image description here

$\endgroup$
5
  • $\begingroup$ I think It works fine with the continuous plot. I had a list of values, and I plotted with circled plot marker I am still having trouble getting the mirrored image. the moment I changed to Joined->Flase to Joined -> true, I got the reflected plot $\endgroup$
    – acoustics
    Aug 2, 2019 at 11:16
  • $\begingroup$ Could you please change the plotmaker as circle once and check. because it seems like it does not work for plot other than line $\endgroup$
    – acoustics
    Aug 2, 2019 at 11:19
  • $\begingroup$ sorry again I lost, why it lost the mirror reflection? I tried tweaking the - sign in your code , seems it not working for me $\endgroup$
    – acoustics
    Aug 2, 2019 at 11:45
  • 1
    $\begingroup$ it works as expected in v9. in v12 there is something wrong. $\endgroup$
    – kglr
    Aug 2, 2019 at 12:02
  • $\begingroup$ @acoustics, please see the update. $\endgroup$
    – kglr
    Aug 2, 2019 at 13:06
1
$\begingroup$

ReflectionTransformneeds two arguments in this case

Show[{gr, 
gr /. L_Line :> {Red,GeometricTransformation[L,ReflectionTransform[{0, -1}, {0,-1}]]}}, PlotRange -> All,ImageSize -> 200 , GridLines -> {None, {{-1, Green}}}]

enter image description here

$\endgroup$
2
  • $\begingroup$ But there is a new line which is coming in green colour? $\endgroup$
    – acoustics
    Aug 2, 2019 at 11:02
  • 1
    $\begingroup$ That's a Gridline to visualize the refelcting plane. Remove GridLine->... $\endgroup$ Aug 2, 2019 at 11:16

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.