I prefer single-line axes for plots, rather than the box style which is (I think) the default for PGFPlots. I'm familiar with the axis x line*=middle
option, which places the x-axis at y=0. However, I often need to graph temperature data where it would make much more sense to show the axis at y=20 (with data in °C). I haven't been able to find a way to do this. Is there some way to make this happen?
I'd prefer not to just use a \draw
command to manually create the axis because then I would need to manually create ticks, labels, etc.
Edit to clarify what I'm asking:
I'd like to achieve this, but without the kludge for the x-axis.
\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=none,
axis y line=middle,
xmin=0,
ymin=5,
ymin= 10,
ymax=30,
xlabel=$x$,
ylabel=$y$,
]
\addplot coordinates {(0,20) (1,24) (2,28) (3,18) (4,21) (5,27)};
\coordinate (start) at (axis cs:0,20);
\coordinate (end) at (axis cs:5,20);
\end{axis}
\draw[->] (start) -- (end);
\end{tikzpicture}
\end{document}