5

In my MWE below, I am not getting the markers of the plots to colors that I wanted. Also, I would like to change the red squares in the last plot to cyan circles. Thanks.

Here is my code:

\documentclass{book}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}

\begin{filecontents*}{data.csv}
  Iter   Abs1   Abs2      x      y
     1, 0.9317521, 1.1849326, 1.6130556, 0.8022207
     2, 1.8946202, 1.1228282, 1.8964566, -0.5353802
     3, 1.5243302, 1.0372991, 1.4375012, 0.9719003
     4, 1.5797030, 1.1346832, 1.8717142, 0.3138737
     5, 1.8814457, 1.0529187, 2.0568468, -0.5509391
     6, 2.0435003, 1.0470546, 2.0621956, -0.3565483
     7, 2.0373926, 1.1215579, 2.1836100, 0.3360301
     8, 1.9797077, 1.1632352, 1.8299063, 0.3871091
     9, 1.9972528, 1.1952478, 1.8133509, -0.0867033
    10, 1.8320176, 1.0625633, 1.0727495, 1.7256738
\end{filecontents*}

\begin{document}
\begin{tikzpicture}
\begin{axis}[width=14cm,height=8cm, title = {\emph{(a) $P_{T}$ over different samples}}, xlabel={$x~Position$},ylabel={$y~Position$}]

% Graph column 2 versus column 0
\addplot+ table[x index=3,y index=4,col sep=comma, only marks,mark=*,mark options={scale=2, fill=white}] {data.csv};
%\addlegendentry{Column 3}% y index+1 since humans count from 1

\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[width=14cm,height=8cm, title = {\emph{(b) RSLE Parameter Errors in terms of Recursions RSLE}},xlabel={$Number~of~Recursions$},ylabel={Absolute Parameter Error}]

% Graph column 1 versus column 0
\addplot table[x index=0,y index=1,col sep=comma, green, only marks] {data.csv};
\addlegendentry{$\delta_{r2}$}

% Graph column 1 versus column 0
\addplot table[x index=0,y index=2,col sep=comma, cyan, only marks] {data.csv};
\addlegendentry{$\delta_{r3}$}
\end{axis}
\end{tikzpicture}

\end{document} 
6

I don't know the exact reason but if your mark options go before table then everything works.

\documentclass{book}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}

\begin{filecontents*}{data.csv}
  Iter   Abs1   Abs2      x      y
     1, 0.9317521, 1.1849326, 1.6130556, 0.8022207
     2, 1.8946202, 1.1228282, 1.8964566, -0.5353802
     3, 1.5243302, 1.0372991, 1.4375012, 0.9719003
     4, 1.5797030, 1.1346832, 1.8717142, 0.3138737
     5, 1.8814457, 1.0529187, 2.0568468, -0.5509391
     6, 2.0435003, 1.0470546, 2.0621956, -0.3565483
     7, 2.0373926, 1.1215579, 2.1836100, 0.3360301
     8, 1.9797077, 1.1632352, 1.8299063, 0.3871091
     9, 1.9972528, 1.1952478, 1.8133509, -0.0867033
    10, 1.8320176, 1.0625633, 1.0727495, 1.7256738
\end{filecontents*}

\begin{document}
\begin{tikzpicture}
\begin{axis}[width=14cm,height=8cm, title = {\emph{(a) $P_{T}$ over different samples}}, xlabel={$x~Position$},ylabel={$y~Position$}]

% Graph column 2 versus column 0
  \addplot[only marks,mark=o,mark options={fill=white,scale=2}] table[x index=3,y index=4,col sep=comma] {data.csv};   % CHANGE HERE
%\addlegendentry{Column 3}% y index+1 since humans count from 1

\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[width=14cm,height=8cm, title = {\emph{(b) RSLE Parameter Errors in terms of Recursions RSLE}},xlabel={$Number~of~Recursions$},ylabel={Absolute Parameter Error}]

% Graph column 1 versus column 0
  \addplot[only marks,mark=*,mark options={fill=green}] table[x index=0,y index=1,col sep=comma] {data.csv};   % CHANGE HERE
\addlegendentry{$\delta_{r2}$}

% Graph column 1 versus column 0
\addplot[only marks,mark=*,mark options={fill=cyan}] table[x index=0,y index=2,col sep=comma] {data.csv}; % CHANGE HERE
\addlegendentry{$\delta_{r3}$}
\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.