0

How do I add a cross, (say + shape or x) as a graphic to a plot in a similar way as I would add a point using Point.

Existing solutions (https://mathematica.stackexchange.com/a/155162/45020) seem to always use a whole extra listplot. This seems cumbersome for just adding one point.

Additionally I noticed that the two lines of the cross for some reason don't cross in the middle in that answer (most noticeable if you take FontSize -> 15).

So how do I add a + or - shape to a plot, centered at the point I give it and with the obvious required symmetries regardless of the size of the marker.

I would be hoping for something of the form Show[plot,Graphics[cross[{x, y}]]] with very similar behavior to Point but instead showing a cross.

Kvothe
  • 4,419
  • 9
  • 28
  • I don't understand the question. Do you want to change the plot marker in ListPlot? Or do you want to add a single cross to an arbitrary existing graphic? Also, if you know how to add a point with Point, adding a cross is exactly the same, with two Lines. Please clarify and address these. – Szabolcs Dec 09 '19 at 11:54
  • I would prefer not to add a whole ListPlot and instead add a Graphics object. I could do this with two lines. But I would want to declare some function cross[xylist_] that takes only the center around which there should be a cross and not all the endpoints of the lines. Perhaps the best solution is something of this form but I would still need to do something complicated in order to find the required length of the lines so that I get an absolute size and not something that depends on the data. – Kvothe Dec 09 '19 at 12:57
  • Intuitively what I want to do is just Show[plot,Graphics[Point[{x, y}]]], but with Point replaced with cross producing a cross at the place of the point. – Kvothe Dec 09 '19 at 12:59
  • 1
    You could write a tiny function that takes a coordinate pair and construct a cross on top of it from Lines. Then you can use with with Epilog or with Show (as in your example). Offset coordinates will be useful for consistent sizing. – Szabolcs Dec 09 '19 at 15:07
  • 2
    Looks like a use case for my PolygonMarker function. – Alexey Popkov Dec 09 '19 at 16:19
  • @MarcoB, indeed it might contain the answer. On a side note, it is kind of bad if the canonical answer in all versions is only found in a question that seems to be specifically about how to keep working with old versions of Mathematica. In fact it seems that the before version 10 part of the question is not that important yet it has very prominent place in the title. – Kvothe Dec 09 '19 at 16:45
  • 1
    Here's a cross function. The second argument is the size in printer's points. It acts like AbsolutePointSize and is independent of the figure size. cross[pos_, s_] := {Line[{Offset[{-s, 0}, pos], Offset[{s, 0}, pos]}], Line[{Offset[{0, -s}, pos], Offset[{0, s}, pos]}]} – Szabolcs Dec 09 '19 at 18:29

0 Answers0