2

I am trying to use the pin options to draw a |- path from a node defined on a line plot to point the axis corresponding to the plot. My current code and output is as follows.

\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}

enter image description here

Is it possible to draw a |-> path, instead of a -> path from a node (`A' in this case) defined on the line plot, to show the x- and y-axis corresponding to the different plots?

0
2

I assume you want the (left,top) axis combination to point left and up, etc. It might be a good idea not to assign every coordinate the same name.

\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}

demo

4
  • I need something similar to what you have suggested except I was trying something like \draw[->] (A) |- +(-0.5,-0.5); for the first arrow to show that the first line plot corresponds to the axis on the left but the relative coordinate doesn't work with A. Jun 5 '17 at 19:52
  • I think I figured out what you are trying to do now. Am having difficulty uploading the new image though. Jun 5 '17 at 19:59
  • that's exactly what I was looking for. I guess what I had should have also worked except my relative increment (0.5 pt) was too small for me to notice any change. Thanks for pointing out the role of dimensions in this instance. Jun 5 '17 at 21:34
  • Drawing inside a pgfplots axis environment is tricky. The dafault coordinate system is (axis cs: ...). With earlier versions you had to put all tikz commands inside \pgfplotsextra, but that seems to be fixed now. Jun 6 '17 at 3:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.