0

I'm using

\definecolor{kitgreen}{rgb}{0,0.588235294117647,0.509803921568627}
\definecolor{kitblue}{rgb}{0.274509803921569,0.392156862745098,0.666666666666667}

\begin{tikzpicture} \begin{axis}[% ycomb, xmin=0, xmax=21, ymin=0, ymax=1.2, ]

\draw[<->,red] (100,31) -- (100,80); %why does this work? \draw[<->,blue] (10,0.31) -- (10,0.8); %should work, but doesn't.

\draw[black,dashed] ({rel axis cs:0.95,0}|-{axis cs:0,1}) -- ({rel axis cs:0,0}|-{axis cs:0,1}); \draw[black,dashed] ({rel axis cs:0.95,0}|-{axis cs:0,0.8}) -- ({rel axis cs:0,0}|-{axis cs:0,0.8}); \draw[black,dashed] ({rel axis cs:0.95,0}|-{axis cs:0,0.31}) -- ({rel axis cs:0,0}|-{axis cs:0,0.31}); \addplot+ [semithick,color=black,mark=*,mark options={fill=white}] table[row sep=crcr]{% 1 0.194\ 2 0.18\ 4 0.215\ 5 0.192\ 6 0.189\ 8 0.214\ 9 0.221\ 10 0.176\ 11 0.223\ 12 0.178\ 13 0.199\ 14 0.222\ 15 0.179\ 16 0.229\ 17 0.184\ 18 0.19\ 19 0.175\ 20 0.224\ }; \addplot+ [semithick,color=kitgreen,mark=*,mark options={fill=white}] table[row sep=crcr]{% 3 0.8\ }; \addplot+ [semithick,color=kitblue,mark=*,mark options={fill=white}] table[row sep=crcr]{% 7 0.31\ }; \end{axis} \end{tikzpicture}

Why is the red arrow showing correctly (x scaled by 10, y scaled by 100) but the blue one isn't? I would expect the blue arrow at x=10.

result

  • I think it works. You can see the lower blue arrow tip at (1,0), but the upper blue arrow tip is under the axis (hence not shown). You probably are mistaken by your scaling. – SebGlav Jul 26 '21 at 18:06
  • 1
    Looking at the screenshot, the red one doesn't work, in that the position doesn't correspond to the coordinates used. That said, the reason it doesn't work is probably that by default, coordinates for \draw etc. inside an axis does not correspond to the axis coordinates. Use (axis cs:1,1) to explicitly use the axis coord system. Or add \pgfplotsset{compat=1.11} to the preamble, with that setting (1,1) and (axis cs:1,1) will work the same, because axis cs becomes default. – Torbjørn T. Jul 26 '21 at 18:11
  • Thanks Torbjørn, i didn't know that. Can you formulate a full answer? I'll mark is as solved then. – Marvin Noll Jul 26 '21 at 18:36
  • 1
    Very likely a duplicate question can be found, so I'll look for that first. (By the way, if you write @<username>, e.g. @MarvinNoll, the user will be notified of your comment. You who posted the question is always notified of new comments, other users are not.) – Torbjørn T. Jul 26 '21 at 18:40

0 Answers0