2
$\begingroup$

I am making a customized plot marker mk2 (a black star) with Polygon. Another marker mk1 (a red circle) I made with Circle is properly centered. However, I could not figure out how to make mk2 centered at {0,0} so I can use it later to mark properly some data points without shifting. Here is the code:

mk1 = {AbsoluteThickness[1.5], Red, Circle[{0, 0}, Scaled[0.02]]} // 
  Graphics
l = 1/50; k = 1/150;
mk2 = Polygon[
   Scaled /@ {{l, 0}, {k, k}, {0, l}, {-k, k}, {-l, 
       0}, {-k, -k}, {0, -l}, {k, -k}}] // Graphics
Show[mk2, mk1, Axes -> True]

enter image description here

The coordinates of mk2 need to be given in Scaled numbers. How can I make mk2 also centered at {0,0}?

$\endgroup$
6
$\begingroup$

Use Scaled[offset, location] instead:

mk1 = Graphics[
    {AbsoluteThickness[1.5], Red, Circle[{0,0}, Scaled[0.02]]}
];
l = 1/50; k = 1/150;
mk2 = Graphics[
    Polygon[Scaled[#,{0,0}]&/@{{l,0},{k,k},{0,l},{-k,k},{-l,0},{-k,-k},{0,-l},{k,-k}}],
    Axes->True
];
Show[mk2,mk1]

enter image description here

$\endgroup$
1
$\begingroup$

An alternative is to Scale the polygon with ordinary coordinates:

s = .02;
mk1 = Graphics@ {AbsoluteThickness[1.5], Red, Circle[{0, 0}, Scaled[s]]};
l = 1; k = 1/3; 
mk2 = Graphics @ 
    Scale[Polygon[{{l, 0}, {k, k}, {0, l}, {-k, k}, {-l,  0}, {-k, -k}, {0, -l}, {k, -k}}], 
     2 s];
Show[mk2, mk1, Axes -> True, PlotRange -> {{-1, 1}, {-1, 1}}]

enter image description here

$\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.