For example ListLinePlot[Range[10000], PlotTheme -> "Monochrome"]
will show a marker for every point, how can I show a marker just every hundred points?
As of Version 12.1 do not use PlotTheme -> "Monochrome"
(see update below)
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
:
SeedRandom["08.01.2019"];
points = RandomVariate[ UniformDistribution[], 50 ];
ListLinePlot[
points,
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:
So for completeness' sake using Mesh
the solution to the OP's problem is approximately:
ListLinePlot[Range[10000], Mesh -> (10000/100), PlotTheme -> "Monochrome"]
UPDATE:
It seems that some things are broken in Version 12.1 as my solution will not work out (@XinBae points out, that earlier Versions had similiar issues).
I found the culprit: It is PlotTheme -> "Monochrome"
which seems to break Mesh
.
Compare the following output:
SeedRandom["08.01.2019"];
points = Sort@RandomVariate[UniformDistribution[], 50];
GraphicsRow@{
ListLinePlot[points, Mesh -> 2, PlotTheme -> "Detailed"],
ListLinePlot[points, Mesh -> 2, 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 '19 at 10:55
-
1
-
$\begingroup$ So why is this answer downvoted? Someone angry because of COVID-19? ;-) $\endgroup$ – gwr May 25 '20 at 18:33
-
2$\begingroup$ Maybe not the COVID-19. This method fails in version 12.1... In fact, in some previous versions, the mesh option also failed @gwr $\endgroup$ – XinBae Jun 2 '20 at 1:06
-
$\begingroup$ @XinBae I see. The culprit is
PlotTheme -> "Monochrome"
see my update. $\endgroup$ – gwr Jun 2 '20 at 18:05
This will do it:
ListLinePlot[Range[10000][[1;;-1;;100]], PlotTheme -> "Monochrome"]
The [[1;;-1;;100]]
part specification picks one element every 100 elements.
-
-
2
-
$\begingroup$ @gwr You can always make two plots and combine them with
Show
- oneListLinePlot
without markers, and oneListPlot
employing this solution to get a marker every 100 points $\endgroup$ – Lukas Lang Jan 8 '19 at 8:18 -
1$\begingroup$ @gwr What I meant is that you make the
ListLinePlot
with all data points, and only theListPlot
with the subset. Or do you mean something else? $\endgroup$ – Lukas Lang Jan 8 '19 at 8:25 -
1$\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 '19 at 8:26