Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Intervals of Markers in Mathematica PlotMarkers

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}.

like image 235
o4tlulz Avatar asked Jan 25 '11 01:01

o4tlulz


4 Answers

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

like image 147
Brett Champion Avatar answered Nov 02 '22 19:11

Brett Champion


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...

like image 41
Simon Avatar answered Nov 02 '22 20:11

Simon


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

like image 2
Dr. belisarius Avatar answered Nov 02 '22 20:11

Dr. belisarius


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

like image 1
o4tlulz Avatar answered Nov 02 '22 20:11

o4tlulz