0

I use the following code to draw an arrow in Tikz with \pgfplotsset{compat = 1.3}:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.3}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[xmin=0,xmax=10,ymin=0,ymax=10,ylabel={Some values},ylabel shift = -10pt]
            \draw[->,thick] (3,3) -- (4,4);
        \end{axis}
    \end{tikzpicture}
\end{document}

but I get the arrow at a wrong location. I need to use at least the version 1.3 because I need the command ylabel shift to shift the label on pgfplots (as adviced in this answer).

Has anyone encountered the same problem?

  • 3
    Add axis cs: to \draw[->,thick] (650,66) -- (530,69); like \draw[->,thick] (axis cs:650,66) -- (axis cs:530,69);. – ferahfeza Mar 1 at 12:22
  • 1
    upgrade this ancient pgfplots version with recent 1.16 :-). it has beside all from 1.3 all (a lot of) improvements ... and show an example with command ylabel shift. – Zarko Mar 1 at 12:26
  • Thank you! I solved the problem with axis cs:. I use \pgfplotsset{compat = 1.3} as advised in this answer for ylabel shift. – TheSunnyDay Mar 1 at 12:38
  • 1
    In the cited answer it say "(You will need to have \pgfplotsset{compat = 1.3} or a higher version number for this to work.)", emphasis mine. So 1.16 is OK, because 16 is greater than 3... – Rmano Mar 1 at 23:00
1

The issue can be solved by adding axis cs: to \draw[->,thick] (650,66) -- (530,69):

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.3}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[xmin=0,xmax=10,ymin=0,ymax=10,ylabel={Some values},ylabel shift = -10pt]
            \draw[->,thick] (axis cs:3,3) -- (axis cs:4,4);
        \end{axis}
    \end{tikzpicture}
\end{document}

As suggested in this comment.

Another possible solution is to use a a higher version of pgfplots (\pgfplotsset{compat = 1.16}):

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.16}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[xmin=0,xmax=10,ymin=0,ymax=10,ylabel={Some values},ylabel shift = -10pt]
            \draw[->,thick] (3,3) -- (4,4);
        \end{axis}
    \end{tikzpicture}
\end{document}

As suggested in this comment.

  • 3
    (i) but you should show where and how you use ylabel shift, (ii) you should first ask @ferahfeza that convert his comment to answer ... – Zarko Mar 1 at 13:41
  • 1
    ... And in a recent pgfplot, you'll have both ylabel shift and axis cs as a default. I think that the OP is thinking that 1.3 is greater than 1.16...For which I can sympathize with. – Rmano Mar 1 at 23:03
  • I have added how to use ylabel shift, and merged in the solution the possibility of using a higher version of pgfplots. How should I contact the users to write the answers? – TheSunnyDay Mar 2 at 11:46
  • @Rmano yes I was indeed confused, I thought 1.3>1.16... Thanks for your help! – TheSunnyDay Mar 2 at 11:56

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.