答案1
你可以使用pgfplots
绘制轴并包含图像\addplot graphics
。
\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{units}
\pgfplotsset{compat = 1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
axis line style = -,
axis line shift = 2mm,
every tick/.append style = {black, thin},
tick align = outside,
unit markings = parenthesis,
xlabel = {$x$},
x unit = {m},
ylabel = {$y$},
y unit = {m}
]
\addplot graphics [
xmin = 0,
xmax = 4,
ymin = -2,
ymax = 2
]
{example-image-a};
\end{axis}
\end{tikzpicture}
\end{document}
答案2
这是一个基本设置,您可以根据需要进行调整。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[font=\sffamily]
\fill (0,-2) rectangle (4,2);
\begin{scope}[yshift=-2mm]
\draw (0,-2) --node[yshift=-9mm]{$\mathsf{x(m)}$} (4,-2);
\foreach \x in {0,...,4}{\draw (\x,-2)--(\x,-2.2) node[below]{\x};}
\end{scope}
\begin{scope}[xshift=-2mm]
\draw (0,-2) --node[yshift=9mm, sloped]{$\mathsf{y(m)}$} (0,2);
\foreach \y in {-2,...,2}{\draw (0,\y)--(-.2,\y) node[left]{\y};}
\end{scope}
\end{tikzpicture}
\end{document}