在下面的 MWE 中,我没有将绘图的标记设置为我想要的颜色。另外,我想将最后一个绘图中的红色方块更改为青色圆圈。谢谢。
这是我的代码:
\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}
答案1
我不知道具体的原因,但如果您的标记选项位于表格之前,那么一切都会正常。
\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}