[Tex/LaTex] marker on every n points only in pgfplots

pgfplots

I use the following command to plot data from a file using pgfplots.

\addplot table [x expr=\coordindex+1,y index=0]{file.txt}

I have around 8 curves in the same plot and lot of data points in the files that when I plot the graph, the graph is very thick and the different curves cannot be distinguished from each other. As a solution, how to make the marker appear only on every n points?

Best Answer

You can use mark repeat={<integer>}, where the positive <integer> causes to draw only each n-th mark. A little example:

\begin{filecontents*}{mytable.dat}
dof L2
5   8.31160034e-02
17  2.54685628e-02
49  7.40715288e-03
69  2.10192154e-03
71  5.87352989e-04
92  1.62269942e-04
\end{filecontents*}
\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{loglogaxis}[
xlabel=Dof,
ylabel=$L_2$ error]
\addplot table[x=dof,y=L2] {mytable.dat};
\end{loglogaxis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{loglogaxis}[
xlabel=Dof,
ylabel=$L_2$ error,
mark repeat={2}]
\addplot table[x=dof,y=L2] {mytable.dat};
\end{loglogaxis}
\end{tikzpicture}

\end{document}

enter image description here