我有一个与某些点相对应的置信区间图。我想以某种方式强调某些点(例如 $x_1,x_2,x_3$)都属于同一集合 $M$。我的想法是在图表的底部(或顶部)放置一个水平括号,并标上 $M$。欢迎提供任何有关实现此目的的帮助或其他想法。谢谢。
\begin{figure}
\begin{tikzpicture}[scale=1],
\centering
\begin{axis}[
height=7cm,
width=13cm,
ymax=5,
ymin=0,
xmin=0.5,
xmax=10,
axis y line*=left,
axis x line*=bottom,
xticklabels={$x_1$,$x_2$,$x_2$,$x_3$, $x_4$,$x_5$,$x_6$,$x_7$,$x_8$, $x_9$},xtick={1,...,10},
x tick label style={anchor=north}]
\addplot+[only marks][error bars/.cd,y dir=both, y explicit]
coordinates {
(10,0.23333) +- (0.5,-0.2)
};
\addplot[dashed] coordinates {(0,0) (10,0)};
\end{axis}
\end{tikzpicture}%
\end{figure}
答案1
为了突出显示点 $x_1$、$x_2$ 和 $x_3$ 属于同一集合 $M$,您可以在这些点下方添加水平括号以及标签“$M$”。您可以使用 TikZ 中的括号修饰来实现这一点。以下是修改现有 TikZ 代码的方法:
\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[scale=1]
\begin{axis}[
height=7cm,
width=13cm,
ymax=5,
ymin=0,
xmin=0.5,
xmax=10.5,
axis y line*=left,
axis x line*=bottom,
xticklabels={$x_1$,$x_2$,$x_2$,$x_3$, $x_4$,$x_5$,$x_6$,$x_7$,$x_8$, $x_9$},
xtick={1,...,10},
x tick label style={anchor=north}]
\addplot+[only marks][error bars/.cd,y dir=both, y explicit]
coordinates {
(10,0.23333) +- (0.58257,-0.2159)
(9,1.4) +- (2.04003,0.75997)
(8,1.1) +- (1.82293,0.47707)
(7,1.3667) +- (2.0352,0.6981)
(6,0.44667) +- (0.94558,-0.41225)
(5,3.5) +- (0.59648,-0.59648)
(4,0.9) +- (1.67431,0.42569)
(3,1.5667) +- (0.09502,0.92835)
(2,0.56667) +- (1.30495,-0.37162)
(1,0.4) +- (1.06941,-0.26941)
};
\addplot[dashed] coordinates {(0,0) (10.5,0)};
\end{axis}
% Brace and label
\draw [decorate,decoration={brace,amplitude=10pt,mirror},xshift=-4pt,yshift=-5pt]
(1.8,0) -- (4.2,0) node [black,midway,yshift=-15pt] {$M$};
\end{tikzpicture}
\end{figure}
\end{document}