Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Two questions, but I am not sure whether they are already answered or not.

  • How can I create PlotMarkers (in ListLinePlot) with less points (less markers)? Or markers with some intervals. I have tried the Mesh option, but it does not work; it messes up all the plots.

  • Is it possible to create PlotMarkers for normal Plot, not ListPlot? One way is to export the data to the list, but I would like to do it directly.

More information: Suppose ListLinePlot of a number of data lists with legends. based on the suggestions, I have changed my plots into this, but honestly I cannot understand how it works!

style = Sequence @@ {Frame -> {{True, False}, {True, False}}, 
   FrameTicks -> {{0, 1, 2, 3}, {0, 0.4, 0.8, 1.5}, None, None}, 
   FrameStyle -> Directive[Black, 16, FontSlant -> Plain], 
   LabelStyle -> Directive[FontSlant -> Plain], 
   AxesStyle -> Lighter@Gray, TicksStyle -> Black, 
   LabelStyle -> {GrayLevel[0], 14, FontSlant -> Plain, 
     FontFamily -> "Helvetica"}, ImageSize -> 300, 
   AspectRatio -> 1/GoldenRatio}

  ListLinePlot[{c1, c2, c3, c4}, PlotRange -> Full, 
  Evaluate@style, 
  PlotLegends -> Placed[{Long, S_Short, Short, Flexible}, Below], 
  PlotStyle -> (Directive[
       AbsoluteThickness[2], #] & /@ (ColorData[81] /@ Range[6])), 
  MeshFunctions -> {Abs[#1] &, Abs[#1] &, Abs[#1] &, Abs[#1] &}, 
  Mesh -> 6, PlotMarkers -> {Automatic, 20}, 
  MeshStyle -> {ColorData[81] /@ Range[6], ColorData[81] /@ Range[7], 
    ColorData[81] /@ Range[8], ColorData[81] /@ Range[9]}]

The output is something like this, where as you can see each Markers has all the colours together. How can I solve this problem and improve it? Another problem is the distribution of the Markers which is not good.

the output!

share|improve this question
    
Regarding the first question you could create two plots, one with the ListLinePlot with all the data, the second would be a ListPlot with the desired number of data (e.g. each 2) with PlotMarkers. Then Show would make it fit :) –  Öskå Jun 11 at 21:37
    
Regarding the second question, I think this should help. –  Öskå Jun 11 at 21:38
    
@Öskå Thanks for your replies. Let me try! –  Arash Jun 11 at 21:41
    
@Öskå, your first answer works, but how can I handle the PlotLegends in this case? –  Arash Jun 11 at 21:54
    
I don't have v9 so I don't know much about PlotLegends. Does Show remove it? –  Öskå Jun 11 at 21:59

3 Answers 3

up vote 5 down vote accepted

First question if you don't want to play with Mesh you could do:

data = Thread@{Range@10, Range[1, 100, 10]}
llp = ListLinePlot[data];
lp[n_] := ListPlot[data[[1 ;; Length@data ;; n]], PlotMarkers -> Automatic];
Table[Show[llp, lp@i], {i, 1, 10, 2}]

enter image description here

Second question:

Eldo's answer or Mr.Wizard's answer:

Plot[x, {x, 1, 10}, Mesh -> 5] /. 
 Point[x : {__Integer}] :> Map[Inset["■", #] &, x]

Mathematica graphics

share|improve this answer
    
You can do both at once with something like Point[x:{__Integer}]:> Map[Inset["■", #] &, x[[;;;;5]]] (+1) –  kguler Jun 11 at 23:20
    
@Öskå, I could not solve the problem so I used your idea of combining two plots together. Thank you and the other for your help. –  Arash Jun 14 at 19:53

MeshStyle option setting can be a function, so you can use that function to reduce the number of mesh points and to specify the markers:

Row[{Plot[x, {x, 1, 10}, Mesh -> 20, ImageSize -> 400, MeshStyle -> Red],
     Plot[x, {x, 1, 10}, Mesh -> 20, ImageSize -> 400, 
       MeshStyle -> 
        (Map[Inset[Style["\[FilledSquare]", Red, 36], #] &, #[[;; ;; 4]]] & @@ ## &)]},
 Spacer[5]]

enter image description here

One can use the same trick with ListLinePlot:

data = Thread@{Range@10, Range[1, 100, 10]};
Row[{ListLinePlot[data, Mesh -> All, ImageSize -> 400, MeshStyle -> Red],
   ListLinePlot[data, Mesh -> All, ImageSize -> 400, 
    MeshStyle -> 
      (Map[Inset[Style["\[FilledSquare]", Blue, 16], #] &, #[[;; ;;3]]] & @@ ## &)]}, 
 Spacer[5]]

enter image description here

share|improve this answer
    
That's much better indeed :) –  Öskå Jun 12 at 8:53
    
@kguler, Thank you. I am trying to do it for multiple data lists and include legends as well. I will comment if I fail. –  Arash Jun 12 at 9:56

Regarding the second part of your question:

Plot[Sin[x], {x, 0, 2 Pi}, Mesh -> {Range[0, 2 Pi, Pi/4]}, 
 MeshStyle -> PointSize[Medium]]

enter image description here

Plot[Sin[x], {x, 0, 2 Pi}, Mesh -> {Range[0, 2 Pi, Pi/8]}, 
 MeshStyle -> PointSize[Medium]]

enter image description here

As to the first part of your question: Follow the link provided by Öska.

share|improve this answer
    
@Öska - please change ListPlott (I tried to edit, but you have to change more than just one character). –  eldo Jun 11 at 22:08
    
I did sorry :) I just noticed.. :) –  Öskå Jun 11 at 22:08
    
@eldo Thank you. I should change it a little for multiple plots with legends. –  Arash Jun 11 at 22:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.