For example ListLinePlot[Range[10000], PlotTheme -> "Monochrome"] will show a marker for every point, how can I show a marker just every hundred points?

  • $\begingroup$ @gwr sorry I commented a bit late, the lab broke the net. $\endgroup$ – xin pei Jan 9 at 2:25

Taking a sample of the points and then working with Overlay or Show (e.g. mixing ListLinePlot, ListPlot) is a rather cumbersome solution. (Note, that just taking a sample of points, as the quickly accepted answer attempts, will not mark every hundredth point - it simply marks all points in a selection.)

There is a better way to achieve what the OP calls for (e.g. marking a selection of all points) by using Mesh:

points = RandomVariate[ UniformDistribution[], 50 ];
    Mesh -> 30, (* setting this to 50-2 = 48 will give all points *)
    PlotTheme -> "Monochrome"


Playing around with the number of points used for Mesh gives the idea:

enter image description here

So for completeness' sake using Mesh the solution to the OP's problem is approximately:

ListLinePlot[Range[10000], Mesh -> (10000/100), PlotTheme -> "Monochrome"]
  • $\begingroup$ @xin pei Note, that the topology of the plot is not affected. You called for less "Markers" not less "Points"! $\endgroup$ – gwr Jan 8 at 10:55
  • $\begingroup$ Yes... Your answer is better $\endgroup$ – xin pei Jan 9 at 2:20

This will do it:

ListLinePlot[Range[10000][[1;;-1;;100]], PlotTheme -> "Monochrome"]

The [[1;;-1;;100]] part specification picks one element every 100 elements.

  • $\begingroup$ Yes, it is. This will work for any list. $\endgroup$ – mmeent Jan 8 at 8:13
  • $\begingroup$ OP wants less marks but not less points. $\endgroup$ – gwr Jan 8 at 8:17
  • $\begingroup$ @gwr You can always make two plots and combine them with Show - one ListLinePlot without markers, and one ListPlot employing this solution to get a marker every 100 points $\endgroup$ – Lukas Lang Jan 8 at 8:18
  • $\begingroup$ @gwr What I meant is that you make the ListLinePlot with all data points, and only the ListPlot with the subset. Or do you mean something else? $\endgroup$ – Lukas Lang Jan 8 at 8:25
  • $\begingroup$ @LukasLang I am saying, that your suggestion will work but I am addressing this answer and it will not work in general. That is all. $\endgroup$ – gwr Jan 8 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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