I tried to plot a sequence with pgfplots but I cannot set the color:

\documentclass[tikz]{standalone}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\pgfmathsetmacro{\Start}{1} %% start value
\pgfmathsetmacro{\End}{5} %% end value
\begin{axis}[mark options={mark=x},only marks,axis lines=center,xlabel=$n$,ylabel=$a_n$,samples at={\Start,...,\End},xtick={0,1,...,\End},grid=both, minor y tick num=4,enlargelimits]
\end{axis}
\end{tikzpicture}

\end{document}


What would be the proper way to specify the color here?

You have to use \addplot+ instead of \addplot. The \addplot version overwrites the default settings with the given options (here only green) and hence the plot is not drawn at all.On the other hand \addplot+ appends the options to the default ones.

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\pgfmathsetmacro{\Start}{1} %% start value
\pgfmathsetmacro{\End}{5} %% end value
\begin{axis}[mark options={mark=x},only marks,axis lines=center,xlabel=$n$,ylabel=$a_n$,samples at={\Start,...,\End},xtick={0,1,...,\End},grid=both, minor y tick num=4,enlargelimits]

• Thanks. That works. But I don't understand why \addplot doesn't. If it overwrites the default settings, then giving no optional argument to it should set the options to nothing (which doesn't seem to be the case). Also it should be possible to write something like \addplot[draw,green] to make it work again. Can you explain this point a bit mor in detail? – Julia Sep 10 '15 at 9:45
• @Julia It is rather \addplot[] that overwrites the defaults. A standalone \addplot doesn't do this. Additional [] clears up the existing style. A plus sign adds to the existing style. – percusse Sep 10 '15 at 10:04
• @percusse. Ok. What would be the correct version of what I intended with \addplot[draw,green]? – Julia Sep 10 '15 at 10:39
• @Julia \addplot[green,mark=*] {1/x}; – LaRiFaRi Sep 10 '15 at 11:37