3

I have a long CSV data file:

x,y1,y2...
1,v1,v1...
2,v2,v2...
....

I use pgfplots to plot all the lines. I also want to add mark shapes. But the problem is that the data is too dense, and I have a limited space, so the marks stick together.

I tried:

 \addplot[blue, thin, mark=square, each nth point=20] table ...

But it also skipped the data points.

I want to have a smooth line, but only a few marks. How can I do that?

  • You need mark repeat key sya mark repeat=10 will repeat marks once in ten. – user11232 Apr 21 '15 at 4:11
6

You need to use mark repeat key to repeat marks at frequent intervals. mark phase will tell at which point the marks should start. For example,

make repeat = r,
mark phase = p

will put the mark first at pth point and then at p+r th and then p+2rth point etc. An example from the manual

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
  \begin{tikzpicture}
\begin{axis}[title=Without \texttt{mark repeat}]
\addplot+[scatter,samples=100] {sin(deg(x))};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[title= With \texttt{mark repeat=5,mark phase=7}]
\addplot+[scatter,samples=100,
mark repeat=5,mark phase=7]
{sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

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.