4

I want the the dots replaced by crosses in the following plot

Plot[Sin[x],{x,0,6.5},PlotStyle ->{Blue,Dotted}] 

Could anyone help please?

kglr
  • 394,356
  • 18
  • 477
  • 896
Jee
  • 314
  • 2
  • 10

1 Answers1

8

Using MeshFunctions->{"ArcLength"} to get equally spaced mesh points and post-processing Points to "\[Cross]"s:

Plot[Sin[x], {x, -2 Pi, 2 Pi}, PlotStyle -> None, Mesh -> 60,
  MeshFunctions -> {"ArcLength"}, MeshStyle -> Blue] /. 
 Point[x_] :> (Text[Style["\[Cross]", 12], #] & /@ x)

Mathematica graphics

Notes:

As noted by @Mr.Wizard in the comments, to get equal arclengths we need to use AspectRatio->Automatic:

Plot[Sin[x], {x, -2 Pi, 2 Pi}, PlotStyle -> None, Mesh -> 60, 
  AspectRatio -> Automatic, MeshFunctions -> {"ArcLength"}, 
  MeshStyle -> Blue, PlotRangePadding -> .2, ImageSize -> 500] /. 
 Point[x_] :> (Text[Style["\[Cross]", 12], #] & /@ x)

Mathematica graphics

Also, as noted in Point Renderings Slightly Off in Mathematica

Precise positioning is not really achievable when glyphs from a font are used as plot markers

This issue can be dealt with using the third argument of Text, e.g., Text[Style["\[Cross]", 30], #, Scaled[{.5, .46}]] as suggested by @Mr.Wizard in the comments (see also this answer by Mr.W). Alternatively, we can make a graphics version of \[Cross]

cross = First[First[ImportString[ExportString[ Style["\[Cross]", Italic,
    FontSize -> 24, FontFamily -> "Times"], "PDF"], "PDF", "TextMode" -> "Outlines"]]]

and use Inset[Graphics[{Blue, cross}, ImageSize -> 8], #] & instead of Text[Style["\[Cross]", 12], #] & above.

kglr
  • 394,356
  • 18
  • 477
  • 896