\documentclass[11pt]{report}
\usepackage{pgfplots, pgfplotstable}
\pgfplotsset{width=10cm,compat=1.18}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[tb]{0.48\linewidth}
\begin{tikzpicture}
\begin{axis}[height=7cm, width=\linewidth, xlabel={}, ylabel={},
ytick={0,500,...,1700},
xtick={0,500,...,1700},
ymin=-170,
ymax=1700,
xmin=-170,
xmax=1700,
ymajorgrids,
xmajorgrids]
\addplot[
scatter/classes={0={blue}, 1={red}},
scatter, mark=*, only marks,
scatter src=explicit symbolic,
nodes near coords*={\Label},
visualization depends on={value \thisrow{label} \as \Label} %<- added value
] table [meta=class] {
x y class label
0.3788 8.1653 0 -
6.3716 4.0196 0 -
0.4225 0.1447 0 -
14.8118 6.6124 0 -
2.7433 2.544 0 -
152.0046 30.6336 1 5
1375 428.5714 1 6
20.51 5.1280 0 -
38.8548 1492.8425 1 8
0.1409 0.000196 0 -
};
\end{axis}
\end{tikzpicture}
\caption{}
\label{}
\end{subfigure}\hfill
\begin{subfigure}[tb]{0.48\linewidth}
\begin{tikzpicture}
\begin{axis}[height=7cm, width=\linewidth, xlabel={}, ylabel={},
ytick={0,2,...,10},
xtick={0,5,...,20},
ymin=-1.133,
ymax=11.333,
xmin=-2.266,
xmax=22.666,
ymajorgrids,
xmajorgrids]
\addplot[
scatter/classes={0={blue}, 1={red}},
scatter, mark=*, only marks,
scatter src=explicit symbolic,
nodes near coords*={\Label},
visualization depends on={value \thisrow{label} \as \Label} %<- added value
] table [meta=class] {
x y class label
0.3788 8.1653 0 9
6.3716 4.0196 0 10
0.4225 0.1447 0 12
14.8118 6.6124 0 13
2.7433 2.544 0 14
20.51 5.1280 0 15
0.1409 0.000196 0 16
};
\end{axis}
\end{tikzpicture}
\caption{}
\label{}
\end{subfigure}\hfill
\caption{}
\end{figure}
\end{document}
> Blockquote
答案1
对于感兴趣的人,我在阅读包装手册后找到了解决方案。虽然我不知道如何将左侧的点重新变成红色。
documentclass[11pt]{report}
\usepackage[T1]{fontenc}
%\usepackage{ngerman}
\usepackage[english,german]{babel}
\usepackage{amsmath,amssymb,amstext}
\usepackage{cuted, nccmath}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{pgfplots, pgfplotstable}
\pgfplotsset{width=10cm,compat=1.18}
%\usepackage{pgfplots} %plots
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[tb]{0.48\linewidth}
\begin{tikzpicture}
\begin{axis}[height=7cm, width=\linewidth, xlabel={}, ylabel={},
ytick={0,500,...,1700},
xtick={0,500,...,1700},
ymin=-170,
ymax=1700,
xmin=-170,
xmax=1700,
ymajorgrids,
xmajorgrids]
\addplot+ [
nodes near coords,
only marks,
coordinate style/.condition=
{\coordindex==6}{below},
coordinate style/.condition=
{x>0 && y>0}{black},
coordinate style/.condition={\coordindex==0}{transparent},
coordinate style/.condition={\coordindex==1}{transparent},
coordinate style/.condition={\coordindex==2}{transparent},
coordinate style/.condition={\coordindex==3}{transparent},
coordinate style/.condition={\coordindex==4}{transparent},
coordinate style/.condition={\coordindex==7}{transparent},
coordinate style/.condition={\coordindex==9}{transparent},
point meta=explicit symbolic,
] table [meta=label] {
x y label
0.3788 8.1653 .
6.3716 4.0196 .
0.4225 0.1447 .
14.8118 6.6124 .
2.7433 2.544 .
152.0046 30.6336 5
1375 428.5714 6
20.51 5.1280 .
38.8548 1492.8425 8
0.1409 0.000196 .
};
\end{axis}
\end{tikzpicture}
\caption{}
\label{}
\end{subfigure}\hfill
\begin{subfigure}[tb]{0.48\linewidth}
\begin{tikzpicture}
\begin{axis}[height=7cm, width=\linewidth, xlabel={}, ylabel={},
ytick={0,2,...,10},
xtick={0,5,...,20},
ymin=-1.133,
ymax=11.333,
xmin=-2.266,
xmax=22.666,
ymajorgrids,
xmajorgrids]
\addplot+ [
nodes near coords,
only marks,
coordinate style/.condition=
{\coordindex==6}{below},
coordinate style/.condition=
{x>0 && y>0}{black},
point meta=explicit symbolic,
] table [meta=label] {
x y label
0.3788 8.1653 9
6.3716 4.0196 10
0.4225 0.1447 12
14.8118 6.6124 13
2.7433 2.544 14
20.51 5.1280 15
0.1409 0.000196 16
};
\end{axis}
\end{tikzpicture}
\caption{}
\label{}
\end{subfigure}\hfill
\caption{}
\end{figure}
\end{document}