![使用 pgfplots 对图中的一组点进行支撑不足](https://linux22.com/image/359488/%E4%BD%BF%E7%94%A8%20pgfplots%20%E5%AF%B9%E5%9B%BE%E4%B8%AD%E7%9A%84%E4%B8%80%E7%BB%84%E7%82%B9%E8%BF%9B%E8%A1%8C%E6%94%AF%E6%92%91%E4%B8%8D%E8%B6%B3.png)
我在同一张图中绘制了两组点。我想用大括号标记它们分组,用大括号标记欠焊或过焊,正如我在此处手工说明的那样:
我正在寻找与数学格式相同类型的钎焊,其中 $$\underbrace{a+b+c}_n$$:
A测试工作代码是:
\documentclass{article}
\usepackage{pgfplots}
\usepackage{xcolor}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{height=7cm, width=8.5cm}
\begin{axis}[
axis lines = left,
hide x axis,
xmin=0, xmax=8,
ymin=600,ymax=1000
]
\addplot[only marks,orange] coordinates {
(1,700)
(2,700)
(3,700)
(4,700)
(5,700)
};
\end{axis}
\begin{axis}[
hide x axis,
hide y axis,
ymin=600,ymax=1000,
xmin=0, xmax=8
]
\addplot[only marks,blue] coordinates {
(6,900)
(7,900)
};
\node at (axis cs:1, 725) {1};
\node at (axis cs:2, 725) {2};
\node at (axis cs:3, 725) {3};
\node at (axis cs:4, 725) {4};
\node at (axis cs:5, 725) {5};
\node at (axis cs:6, 925) {6};
\node at (axis cs:7, 925) {7};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您可以使用它在两点之间decorations={brace}
创建一个支架。tikz
我用 等定义了所需的节点A
,B
以便重复使用这些位置。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{pgfplots}
\usepackage{xcolor}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{height=7cm, width=8.5cm}
\begin{axis}[
axis lines = left,
hide x axis,
xmin=0, xmax=8,
ymin=600,ymax=1000
]
\addplot[only marks,orange] coordinates {
(1,700)
(2,700)
(3,700)
(4,700)
(5,700)
};
\end{axis}
\begin{axis}[
hide x axis,
hide y axis,
ymin=600,ymax=1000,
xmin=0, xmax=8
]
\addplot[only marks,blue] coordinates {
(6,900)
(7,900)
};
\node (A) at (axis cs:1, 725) {1};
\node at (axis cs:2, 725) {2};
\node at (axis cs:3, 725) {3};
\node at (axis cs:4, 725) {4};
\node (B) at (axis cs:5, 725) {5};
\node (C) at (axis cs:6, 925) {6};
\node (D) at (axis cs:7, 925) {7};
\draw [decorate,decoration={brace,amplitude=10pt,mirror,raise=6mm}]
(A.west) -- (B.east) node [black,midway, below, yshift=-10mm] {a};
\draw [decorate,decoration={brace,amplitude=5pt,mirror,raise=6mm}]
(C.west) -- (D.east) node [black,midway, below, yshift=-10mm] {b};
\end{axis}
\end{tikzpicture}
\end{document}