I'm trying to draw arrowed lines that goes like (A) -> (A1) -> (A2) -> (A3), but my code doesn't work.
\documentclass[11pt,a4paper]{article}
\usepackage{geometry}
\usepackage{tikz}
\usepackage{pgfplots, relsize}
\usepgfplotslibrary{polar}
\usepgflibrary{shapes.geometric}
\usetikzlibrary{calc}
\usetikzlibrary{arrows,decorations.markings}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
unit vector ratio*=1 1 1,
grid = none,
axis x line = middle,
axis y line = middle,
xlabel={$k_t$},
xlabel style={at=(current axis.right of origin), anchor=west},
ylabel={$k_{t+1}$},
ylabel style={at=(current axis.above origin), anchor=south},
xmin = 0,
xmax = 15,
scale=1.5,
enlarge y limits={rel=0.13},
enlarge x limits={rel=0.07},
ymin = 0,
ymax = 10, xtick=\empty,ytick=\empty,
after end axis/.code={\path (axis cs:0,0) node [anchor=north west] {0};},
]
\coordinate (0,0) ;
% domain can be set individually!!
\addplot[color=red, domain=0:10,samples=100,smooth,thick] {x} node[above,pos=1] {$45^\circ$};
\addplot[color=blue,domain=0:11,samples=1000,smooth, thick] {3*sqrt(x)} node[right,pos=1] {$W(s,k_{t},\delta)$};
\addplot[color=Cerulean,domain=0:11,samples=1000,smooth, thick] {2*sqrt(x)} node[right,pos=1] {$W(s',k_{t},\delta)$};
\addplot[mark=*,only marks, fill=white] coordinates {(9,9)} node[above, pos=1]{$A$};
\addplot[mark=*,only marks, fill=white] coordinates {(4,4)} node[above, pos=1]{$A'$};
\addplot[mark=*,only marks, fill=white] coordinates {(9,6)} node[below, pos=1]{$A_1$};
\addplot[mark=*,only marks, fill=white] coordinates {(6,6)} node[above, pos=1]{$A_2$};
\addplot[mark=*,only marks, fill=white] coordinates {(6,4.899)} node[below, pos=1]{$A_3$};
\addplot[mark=*,only marks, fill=white] coordinates {(4.899,4.899)} node[above, pos=1]{$A_4$};
% NO output shown at all
\node (A) at (9, 9){};
\node (Ap) at (4, 4){};
\node (A1) at (9, 6){};
\node (A2) at (6, 6){};
\node (A3) at (6, 4.899){};
\node (A4) at (4.899, 4.899){};
\draw [dashed] (A) -- (A1) -- (A2) -- (A3) -- (A4);
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
The output is seriously out of proportion (it's the tiny dashes near the origin in case you couldn't find it). The position and scale are way off. Interestingly, when I put the \node declarations and \draw statement outside {axis}, the output is again way off, but is off in the opposite direction. I believe I haven't defined the \node objects properly with regard to the {axis} coordinates and they all got positioned in some other coordinate frame.
Any idea on how to solve this issue? Thanks!



\pgfplotsset{compat=1.11}(or a higher value) in the preamble or prepend the TikZ coordinates byaxis cs:otherwise thetikzpicturecoordinates and not theaxiscoordinates are used. – Stefan Pinnow Dec 17 '18 at 17:58\draw[->], only the last segment has arrow tip. Thanks! – Vim Dec 17 '18 at 18:08edges for that:\draw [dashed,-latex] (A) edge (A1) (A1) edge (A2) (A2) edge (A3) (A3) edge (A4);. Or you can use decorations. – Dec 17 '18 at 18:09