我尝试在数据点之间画出带有误差线的括号来显示显著差异。
这是我的当前的梅威瑟:
\documentclass[letterpaper]{scrartcl}
\usepackage{tikz,pgfplots}
\begin{document}
\centering\begin{tikzpicture}[domain=0:1, scale=1]
\begin{axis}[ymin=0, ymax=1, xmin=0, xmax=1,
ytick={0,0.2,...,1}, ytick align=outside, ytick pos=left,
xtick={0,0.2,...,1}, xtick align=outside, xtick pos=left,
xlabel={$x$},
ylabel={$y$},
grid=major]
\addplot+[
only marks,
mark options={black, scale=1},
visualization depends on=\thisrow{alignment} \as \alignment,
nodes near coords,
point meta=explicit symbolic,
every node near coord/.style={anchor=\alignment},
error bars/.cd,
y fixed,
y dir=both,
y explicit,
error bar style={width=4pt, line width=4pt, white!60!red}
] table [x=x, y=y,y error=error, col sep=comma, row sep=crcr, meta index=4] {
name, x, y, error, label, alignment\\
a, 0.1, 0.9, 0.03, $y_a$, 0 \\
b, 0.2, 0.8, 0.08, $y_b$, -27 \\
c, 0.5, 0.7, 0.12, $y_c$, 0 \\
d, 1.0, 0.6, 0.15, $y_d$, -25 \\
};
\end{axis}
\end{tikzpicture}
\end{document}
这是我的期望结果:
我希望从表的名称列中引用节点的名称来执行如下操作:
\draw [decorate,decoration={brace,amplitude=5pt,mirror,raise=6mm}]
(a.west) -- (b.east) node [black,midway, below, yshift=-10mm] {*};
这不起作用;我该如何正确引用名称?
以下是几个未能完全解决这个问题的相关问题:
谢谢!!
答案1
我承认,我的方法有点笨拙。但它也非常简单。如果你正确缩放,你可以使用网格线作为参考点,只需填写线号即可。轴为 0,0.2=1,0.4=2 等等……
只要您不需要引用数十或数百个点,这将是一个很好的解决方案。但对于小图形来说,这应该足够了:
\documentclass{standalone}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\centering\begin{tikzpicture}[domain=0:1, scale=1]
\begin{axis}[ymin=0, ymax=1, xmin=0, xmax=1,
ytick={0,0.2,...,1}, ytick align=outside, ytick pos=left,
xtick={0,0.2,...,1}, xtick align=outside, xtick pos=left,
xlabel={$x$},
ylabel={$y$},
grid=major]
\addplot+[
only marks,
mark options={black, scale=1},
visualization depends on=\thisrow{alignment} \as \alignment,
nodes near coords,
point meta=explicit symbolic,
every node near coord/.style={anchor=\alignment},
error bars/.cd,
y fixed,
y dir=both,
y explicit,
error bar style={width=4pt, line width=4pt, white!60!red}
] table [x=x, y=y,y error=error, col sep=comma, row sep=crcr, meta index=4] {
name, x, y, error, label, alignment\\
a, 0.1, 0.9, 0.03, $y_a$, 0 \\
b, 0.2, 0.8, 0.08, $y_b$, -27 \\
c, 0.5, 0.7, 0.12, $y_c$, 0 \\
d, 1.0, 0.6, 0.15, $y_d$, -25 \\
};
\end{axis}
\draw [decorate,decoration={brace,mirror,raise=4ex},scale=1.37,blue,thick]
(1,2.75) -- (2.5,2.75) node[midway,yshift=-2.5em]{$--$};
\draw [decorate,decoration={brace,mirror,raise=4ex},scale=1.37,blue,thick]
(0.5,2) -- (1,2) node[midway,yshift=-2.5em]{$*$};
\draw [decorate,decoration={brace,mirror,raise=4ex},scale=1.37,blue,thick]
(1,2) -- (5,2) node[midway,yshift=-2.5em]{$**$};
\draw [decorate,decoration={brace,mirror,raise=4ex},scale=1.37,blue,thick]
(0.5,1.5) -- (2.5,1.5) node[midway,yshift=-2.5em]{$***$};
\draw [decorate,decoration={brace,mirror,raise=4ex},scale=1.37,blue,thick]
(2.5,1.5) -- (5,1.5) node[midway,yshift=-2.5em]{$--$};
\draw [decorate,decoration={brace,mirror,raise=4ex},scale=1.37,blue,thick]
(0.5,1) -- (5,1) node[midway,yshift=-2.5em]{$***$};
\end{tikzpicture}
\end{document}
您将获得以下内容: