6
$\begingroup$

I would like to have graphical markers available that I can later insert into graphics to mark certain points. I would like those markers to appear at a fixed size (ideally given in terms of font sizes, so if I give a size of "12", say, the marker is the size of a capital letter in a 12-point font). What I have at this point is this:

cmg = Graphics[{FaceForm[Black], Disk[{0, 0}, 1, {0, Pi/2}],
    FaceForm[LightGray], Disk[{0, 0}, 1, {Pi/2, Pi}], FaceForm[Black],
     Disk[{0, 0}, 1, {Pi, 3 Pi/2}], FaceForm[LightGray], 
    Disk[{0, 0}, 1, {3 Pi/2, 2 Pi}]}];
cmarker[{x_?NumericQ, y_?NumericQ}, r_?NumericQ] = 
  Graphics[Inset[cmg, {x, y}, {0, 0}, r], ImageSize -> 50];

Now I do

g1 = {Graphics[{EdgeForm[Thick], Opacity[0.3], Darker[Pink], 
     Rectangle[{-1, -3/4}, {1, 3/4}]}, ImageSize -> 150], 
   cmarker[{0, 0}, 0.5], 
   Graphics[{PointSize[Large], Red, Point[{0, 0}]}]};
g2 = {Graphics[{EdgeForm[Thick], Opacity[0.3], Darker[Pink], 
     Rectangle[{-1, -3/4}, {1, 3/4}]}, ImageSize -> 250], 
   cmarker[{0, 0}, 0.5], 
   Graphics[{PointSize[Large], Red, Point[{0, 0}]}]};
Row[{Show[g1], Show[g2]}]

I get

enter image description here

So, (apart from the minor issue of rescaling to font size; that's easy to solve), my problem is that the markers do change size. How do I prevent this from happening?

$\endgroup$
7
$\begingroup$

Use the graphics directly, you can use Magnify to change the size.

Example.

cmg = Graphics[{FaceForm[Black], Disk[{0, 0}, 1, {0, Pi/2}], 
    FaceForm[LightGray], Disk[{0, 0}, 1, {Pi/2, Pi}], FaceForm[Black],
     Disk[{0, 0}, 1, {Pi, 3 Pi/2}], FaceForm[LightGray], 
    Disk[{0, 0}, 1, {3 Pi/2, 2 Pi}]}];
Multicolumn[
 ListPlot[RandomInteger[10, 5], PlotMarkers -> Magnify[cmg, 0.1], 
    ImageSize -> #] & /@ {100, 200, 300, 400}, {2, 2}]

Mathematica graphics

| improve this answer | |
$\endgroup$
  • $\begingroup$ Hah, that's it, thanks! $\endgroup$ – Pirx Sep 10 '16 at 14:18

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.