Question

I am trying to plot multiple lists in the same plot in Mathematica (ListLinePlot) and use PlotMarkers and the PlotLegend Package to get the final figure. The issue is that Mathematica puts a marker for every point and this makes it hard to tell which marker is where in the plot. Is it possible to have a plot marker appear every n sample (e.g. every 10 points for a 100 point plot).

The Directive at the moment is PlotMarkers->{Automatic, Small}.

Was it helpful?

Solution

If you want more control over the location of the plot markers than Brett's answer gives you, then you probably have to place the markers manually. Eg (modifying Brett's example)

data = Accumulate /@ RandomReal[{-1/2, 1}, {3, 100}];
col = {Red, Blue, Green};
decimate[i_] := {col[[i]], PointSize -> Medium, 
  Point /@ Transpose[{Range[1, 100, 10], data[[i, 1 ;; -1 ;; 10]]}]}
ListLinePlot[data, PlotStyle -> col, Epilog -> Table[decimate[i], {i, 3}]]

enter image description here

Of course Point can be replaced with any graphics object you want - eg Text, Inset etc...

OTHER TIPS

I think adding something like Mesh->10 should work for you:

data = Accumulate /@ RandomReal[{-1/2, 1}, {3, 100}];
ListLinePlot[data, PlotMarkers -> {Automatic, Small}, Mesh -> 10]

ListLinePlot with a fixed number of plot markers

Also remember you can use Tooltip to cause the marker coordinates to pop up when you pass the mouse pointer over it:

enter image description here

The example of what I was describing in the comment. The markers don't behave properly.

Apparently I cannot post images yet, but running the following code

data = Accumulate /@ RandomReal[{-1/2, 1}, {3, 100}];
ListLinePlot[data, PlotMarkers -> {Automatic, Small}, Mesh -> 5]

should give improper results. Also the number of data and plots in the same figure is quite large to individually select which points and I would like to keep the same Directives for different plots and data ranges as they tend to vary between 100 to around 300 in each case and I have to save them in different tables as they are used in other calculations along the way.

Plot Posted by belisarius, running the code above

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top