答案1
尝试这个:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
scatter/classes={
a={mark=*,draw=white,fill=red,mark size=1.5}, % Solid red fill with white outline
b={mark=*,draw=red,fill=red,opacity=0.1,mark size=2} % red mark for the glow
},
]
\addplot[scatter,only marks,
scatter src=explicit symbolic
] table[meta=label] {
x y label
1 1 b
1 1 a
2 2 b
2 2 a
3 3 b
3 3 a
4 4 b
4 4 a
};
\end{axis}
\end{tikzpicture}
\end{document}
在 pgfplots 中,“标记大小”参数可调整绘图标记的大小。
“不透明度”参数可控制其透明度。
答案2
您可以创建自定义绘图标记:
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfdeclareplotmark{* glow}{
\foreach \s in {0,...,5} {
\fill[opacity=0.05, draw=none] (0,0)
circle[radius={2.85pt-\s*0.1pt}];
}
\fill[draw=white, line width=0.5pt] (0,0)
circle[radius=2pt];
}
\pgfdeclareplotmark{triangle glow}{
\foreach \s in {0,...,5} {
\fill[opacity=0.05, draw=none] (90:{3.9pt-\s*0.15pt})
-- (210:{3.9pt-\s*0.15pt})
-- (330:{3.9pt-\s*0.15pt}) -- cycle;
}
\fill[draw=white, line width=0.5pt] (90:2.5pt)
-- (210:2.5pt) -- (330:2.5pt) -- cycle;
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=3cm, height=3cm,
xmin=0, xmax=1,
ymin=0, ymax=1,
xtick={0,1},
ytick={0,1}
]
\addplot[mark=* glow, fill=red] coordinates {(0.2,0.2)};
\addplot[mark=triangle glow, fill=blue] coordinates {(0.8,0.8)};
\end{axis}
\end{tikzpicture}
\end{document}