This does what you suggest, I think. The iaxis
style looks whether the origin is left/right/above/below of the axis boundaries, and adds the arrows accordingly.
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{arrows.meta,calc}
\pgfplotsset{no marks,
iaxis/.style={,axis lines=middle,
inner axis line style={-},clip mode=individual,execute at end axis={
\path[tips=proper] let \p1=($(rel axis cs:1,1)-(axis cs:0,0)$),
\p2=($(axis cs:0,0)-(rel axis cs:0,0)$)
in %\pgfextra{\typeout{\x1,\x2,\y1,\y2}}
\ifdim\x1>0pt
(axis cs:0,0) edge[-{Latex[length=4mm]}] ({rel axis cs:1,0} |- {axis cs:0,0})
\fi
\ifdim\x2>0pt
(axis cs:0,0) edge[-{Latex[length=4mm]}] ({rel axis cs:0,0} |- {axis cs:0,0})
\fi
\ifdim\y1>0pt
(axis cs:0,0) edge[-{Latex[length=4mm]}] ({rel axis cs:0,1} -| {axis cs:0,0})
\fi
\ifdim\y2>0pt
(axis cs:0,0) edge[-{Latex[length=4mm]}] ({rel axis cs:0,0} -| {axis cs:0,0})
\fi;
}},
every axis/.append style=iaxis
}
\begin{document}
\begin{tabular}{cc}
\begin{tikzpicture}
\begin{axis}[domain=0:1]
\addplot+{x};
\end{axis}
\end{tikzpicture} &
\begin{tikzpicture}
\begin{axis}[domain=0:1]
\addplot+{-x};
\end{axis}
\end{tikzpicture}\\
\begin{tikzpicture}
\begin{axis}[domain=-1:0]
\addplot+{x};
\end{axis}
\end{tikzpicture} &
\begin{tikzpicture}
\begin{axis}[domain=-1:0]
\addplot+{-x};
\end{axis}
\end{tikzpicture}\\
\begin{tikzpicture}
\begin{axis}[domain=-1:1]
\addplot+{-x};
\end{axis}
\end{tikzpicture}
\end{tabular}
\end{document}

Or with overshooting arrows (which alter the dimensions of the axis objects).
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{arrows.meta,calc}
\pgfplotsset{no marks,
iaxis/.style={axis lines=middle,
inner axis line style={-},clip mode=individual,execute at end axis={
\path[tips=proper] let \p1=($(rel axis cs:1,1)-(axis cs:0,0)$),
\p2=($(axis cs:0,0)-(rel axis cs:0,0)$)
in %\pgfextra{\typeout{\x1,\x2,\y1,\y2}}
\ifdim\x1>0pt
(axis cs:0,0) edge[-{Latex[length=4mm]}]
($({rel axis cs:1,0} |- {axis cs:0,0})+($(4mm,0)-(0,0)$)$)
\fi
\ifdim\x2>0pt
(axis cs:0,0) edge[-{Latex[length=4mm]}]
($({rel axis cs:0,0} |- {axis cs:0,0})+($(-4mm,0)-(0,0)$)$)
\fi
\ifdim\y1>0pt
(axis cs:0,0) edge[-{Latex[length=4mm]}]
($({rel axis cs:0,1} -| {axis cs:0,0})+($(0,4mm)-(0,0)$)$)
\fi
\ifdim\y2>0pt
(axis cs:0,0) edge[-{Latex[length=4mm]}]
($({rel axis cs:0,0} -| {axis cs:0,0})+($(0,-4mm)-(0,0)$)$)
\fi;
}},
every axis/.append style=iaxis
}
\begin{document}
\begin{tabular}{cc}
\begin{tikzpicture}
\begin{axis}[domain=0:1]
\addplot+{x};
\end{axis}
\end{tikzpicture} &
\begin{tikzpicture}
\begin{axis}[domain=0:1]
\addplot+{-x};
\end{axis}
\end{tikzpicture}\\
\begin{tikzpicture}
\begin{axis}[domain=-1:0]
\addplot+{x};
\end{axis}
\end{tikzpicture} &
\begin{tikzpicture}
\begin{axis}[domain=-1:0]
\addplot+{-x};
\end{axis}
\end{tikzpicture}\\
\begin{tikzpicture}
\begin{axis}[domain=-1:1]
\addplot+{-x};
\end{axis}
\end{tikzpicture}
\end{tabular}
\end{document}

axis lines*=middle
, i.e. adding a*
? – user194703 Sep 29 '19 at 5:18\documentclass{article} \usepackage{pgfplots} \usetikzlibrary{arrows.meta} \pgfplotsset{ no marks,axis lines*=middle, inner axis line style={-{Latex[length=4mm]}} } \begin{document} \begin{center} \begin{tikzpicture} \begin{axis}[domain=0:1] \addplot+{-x}; \end{axis} \end{tikzpicture} \end{center} \end{document}
– user194703 Sep 29 '19 at 5:45