[Tex/LaTex] Uniformly spaced line markers

pgfplotsplottikz-pgf

I'm reading line data from file and plotting it. By default, the curve has markers, where are the original data points. The data points are very uneven, but I would like to have evenly distributed line markers.

MWE (unevenly distributed markers, would like to have for example 5 evenly spaced markers over the whole line):

\documentclass[a4paper,12pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}
\begin{tikzpicture}
    \begin{axis}
     \addplot[mark=*, blue] coordinates {(1, 1) (2, 1) (3, 1) (5, 1) (8, 1) (16, 1)};
    \end{axis}
\end{tikzpicture}
\end{document}

Any way to accomplish this? Thanks in advance.

Best Answer

If I have understood the question correctly, you want to mark the function with markers independently from the data points. Then a decoration helps:

\documentclass[a4paper,12pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\usetikzlibrary{decorations}
\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}
  \begin{axis}
    \addplot[
      blue,
      postaction={
        decoration={
          markings,
          mark=between positions 0 and 1 step 0.2
               with { \fill circle[radius=2pt]; },
        },
        decorate,
      },
    ]   
      coordinates {(1, 1) (2, 1) (3, 1) (5, 1) (8, 1) (16, 1)};
    \addplot[
      red,
      postaction={
        decoration={
          markings,
          mark=between positions 0 and 1 step 0.04
               with { \fill circle[radius=2pt]; },
        },
        decorate,
      },
      domain=0:16,
      samples=200,
    ]
      ({\x}, {sin(\x*180/pi)+1});
  \end{axis}
\end{tikzpicture}
\end{document}

Result

Related Question