答案1
我远不能声称这是“最佳”解决方案,但肯定可以向您的代码添加一些成分,以使结果非常接近所需的屏幕截图。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=0.8\textwidth,
axis equal image,
grid=major,grid style={densely dotted,help lines},
axis x line=bottom,
xmin=-0.5,xmax=9.5,xtick={0,1,...,9},xticklabel=$x_{\pgfmathprintnumber\tick}$,
axis y line=box,
ymin=0,ymax=4.2,ytick={0,1,...,4},yticklabel=$t^{\pgfmathprintnumber\tick}$,
axis line style={draw,thick,-},
]
\path (0,0) coordinate (O) (1,1) coordinate (X) (9,0) coordinate (9);
\end{axis}
\draw[dashed,<->] ([yshift=-1cm]current axis.south-|O) --
node[below] {$h$} ([yshift=-1cm]current axis.south-|X);
\draw[dashed,<->] ([xshift=-1cm]current axis.west|-O) --
node[left] {$k$} ([xshift=-1cm]current axis.west|-X);
\draw[->] (9) -- ++ (1,0);
\path (current axis.south west) node[below]{$0$};
\end{tikzpicture}
\end{document}