0
$\begingroup$

I hope someone can assist me as I am pretty new to Mathematica and understanding the language is a bit of a hurdle.

I am trying to rotate a plot of interlaced circles by some angle without rotating the axis and this is the method that somewhat worked the best.

Show[
    Normal[someplot] /. prim : _Line | _Point | _Polygon :> 
           GeometricTransformation[prim, RotationTransform[Pi/20]], PlotRange -> All, AspectRatio -> Automatic
     ]

From the highest rated answer in the link below:

How to rotate the curve but not the axes?

I would please like to know what the code below is doing. Particularly the "/. prim : _Line | _Point | _Polygon :>" part.

Thank you dearly.

$\endgroup$
1
  • 1
    $\begingroup$ In Mathematica, highlight any unknown symbol and press F1 for help. /. links to ReplaceAll, : links to Pattern, _ links to Blank, and :> links to RuleDelayed. Mathematica provides easy access to docs. $\endgroup$
    – Bob Hanlon
    Nov 11, 2021 at 16:25

1 Answer 1

4
$\begingroup$

Normal[p] is needed to replace GraphicsComplex by a full form with all coodinates.

prim : _Line | _Point | _Polygon is a pattern that matches a line, point or polygon.

:> GeometricTransform[prim,..] replaces the matched line, point or polygon by a rotated version of it.

Here is a small example:

p= Graphics[{Line[{{0, 0}, {1, 1}}], Point[{1, 0.5}]}, Axes -> True]

p /. prim : _Line | _Point | _Polygon :> 
  GeometricTransformation[prim, RotationTransform[Pi/2]] 

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you very much. This was of much help! $\endgroup$
    – Jetty
    Nov 21, 2021 at 19:52

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.