我正在尝试使用 pin 选项从线图上定义的节点绘制一条 |- 路径,以指向与图对应的轴。我当前的代码和输出如下。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{document}
\tikzstyle{every pin edge}=[->,solid]
\begin{tikzpicture}[scale=1.5]
\begin{axis}[
xlabel=X1,
ylabel = Y1,
axis x line* = bottom,
axis y line*=left,
ymin=-1,
ymax = 27,
yticklabels={},
xticklabels={}]
\addplot[mark=diamond*,dashed,mark options={scale=3,solid}] coordinates {(0.6,18) (2.5,14.4) (13.5,8.2) (52.5,1.9)} node [pos=0.13,pin=-180:{}](A){};
\end{axis}
\begin{axis}[
xlabel={\textcolor{red}{X2}},
axis x line* = top,
axis y line*=left,
xticklabels={},
yticklabels={},
ymin=-1,ymax=27,
ytick={}]
\addplot[mark=diamond*,red,dashed,mark options={scale=3,solid}] coordinates {(0,24.7) (3,9.3) (10,3.4) (20,0.8)} node [pos=0.1,pin=-180:{}](A){};
\end{axis}
\begin{axis}[
axis x line* = bottom,
axis y line*=right,
ymin=-1,ymax=20,
xticklabels={},
ylabel=Y2,
yticklabels={}]
\addplot[mark=triangle*,dashed,mark options={scale=3,solid}] coordinates {(0.6,0.1) (2.5,2.1) (13.5,2.6) (52.5,5.9)} node [pos=0.85,pin=0:{}](A){};
\end{axis}
\begin{axis}[
axis x line* = top,
axis y line*=right,
x axis line style = red,
x tick style={color=red},
ymin=-1,ymax=20,
xticklabels={},
ytick={},yticklabels={}]
\addplot[mark=triangle*,red,dashed,mark options={scale=3,solid}] coordinates {(0,0.7) (3,1.9) (10,5.7) (20,17.1)} node [pos=0.85,pin=0:{}](A){};
\end{axis}
\end{tikzpicture}
\end{document}
是否可以绘制一条 |-> 路径,而不是从线图上定义的节点(在本例中为 `A')绘制 -> 路径,以显示对应于不同图的 x 轴和 y 轴?
答案1
我假设您想要(左,上)轴组合指向左和上等等。最好不要为每个坐标分配相同的名称。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{document}
%\tikzstyle{every pin edge}=[->,solid]
\begin{tikzpicture}[scale=1.5]
\begin{axis}[
xlabel=X1,
ylabel = Y1,
axis x line* = bottom,%*suppresses the axis line arrows,
axis y line*=left,
ymin=-1,
ymax = 27,
yticklabels={},
xticklabels={}]
\addplot[mark=diamond*,dashed,mark options={scale=3,solid}] coordinates {(0.6,18) (2.5,14.4) (13.5,8.2) (52.5,1.9)}
coordinate [pos=0.13](A);
\draw[->] (A) |- +(-10pt,-10pt);
\end{axis}
\begin{axis}[
xlabel={\textcolor{red}{X2}},
axis x line* = top,
axis y line*=left,
xticklabels={},
yticklabels={},
ymin=-1,ymax=27,
ytick={}]
\addplot[mark=diamond*,red,dashed,mark options={scale=3,solid}] coordinates {(0,24.7) (3,9.3) (10,3.4) (20,0.8)}
coordinate [pos=0.1](A);
\draw[->,red] (A) |- +(-10pt,10pt);
\end{axis}
\begin{axis}[
axis x line* = bottom,
axis y line*=right,
ymin=-1,ymax=20,
xticklabels={},
ylabel=Y2,
yticklabels={}]
\addplot[mark=triangle*,dashed,mark options={scale=3,solid}] coordinates {(0.6,0.1) (2.5,2.1) (13.5,2.6) (52.5,5.9)}
coordinate [pos=0.85](A){};
\draw[->] (A) |- +(10pt,-10pt);
\end{axis}
\begin{axis}[
axis x line* = top,
axis y line*=right,
x axis line style = red,
x tick style={color=red},
ymin=-1,ymax=20,
xticklabels={},
ytick={},yticklabels={}]
\addplot[mark=triangle*,red,dashed,mark options={scale=3,solid}] coordinates {(0,0.7) (3,1.9) (10,5.7) (20,17.1)}
coordinate [pos=0.85](A){};
\draw[->,red] (A) |- +(10pt,10pt);
\end{axis}
\end{tikzpicture}
\end{document}