我有以下 MWE 来生成图。可以观察到图“path2”的球颜色仍然是蓝色(必须是红色),即使标记颜色被分配为“红色”。因此,我需要更改红线中绘制的“path2”的球颜色。
\documentclass[varwidth=true]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel=Distance from center, ylabel=Appointment,xlabel={Follow-ups},
xlabel style={yshift=-5mm},
xtick={1,2,3,4,5,6,7,8,9,10},
xticklabels = {
\strut A1,
\strut A2,
\strut A3,
\strut A4,
\strut A5,
\strut A6,
\strut A7,
\strut A8,
\strut A9,
\strut A10
},
x tick label style={text width=5em,anchor=north,align=center},
ymin=0,
ymax=20,
grid style=dashed,
legend style={
at={(0.738,0.8209)},
anchor=south west,
},]
\addplot[color=blue, mark=ball, mark color=blue] coordinates{(1,6.5)(2,11)(3,17.4)(4,11)(5,17.4)(6,6.5)(7,17.4)(8,6.5)(9,11)(10,11)};
\addplot[color=red, mark=ball, mark color=red] coordinates{(1,5.9)(2,9.5)(3,13.4)(4,8.5)(5,13.7)(6,6)(7,14.3)(8,5.3)(9,9.2)(10,9.4)};
\legend{path, path2}
\end{axis}
\end{tikzpicture}
\end{document}
答案1
\documentclass[varwidth=true]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel=Distance from center, ylabel=Appointment,xlabel={Follow-ups},
xlabel style={yshift=-5mm},
xtick={1,2,3,4,5,6,7,8,9,10},
xticklabels = {
\strut A1,
\strut A2,
\strut A3,
\strut A4,
\strut A5,
\strut A6,
\strut A7,
\strut A8,
\strut A9,
\strut A10
},
x tick label style={text width=5em,anchor=north,align=center},
ymin=0,
ymax=20,
grid style=dashed,
legend style={
, at={(0.738,0.8209)},
anchor=south west,
},]
\addplot[color=blue, mark=ball, mark color=blue] coordinates{(1,6.5)(2,11)(3,17.4)(4,11)(5,17.4)(6,6.5)(7,17.4)(8,6.5)(9,11)(10,11)};
\addplot[red,mark=ball,mark options={ball color=red}] coordinates{(1,5.9)(2,9.5)(3,13.4)(4,8.5)(5,13.7)(6,6)(7,14.3)(8,5.3)(9,9.2)(10,9.4)};
\legend{path, path2}
\end{axis}
\end{tikzpicture}
\end{document}