0

I want to add axes around a picture with TikZ as shown in the following image. I think I can handle positioning the axes, but how can I set them to have this kind of look, rather than being just usual axes ?

Wanted output

Thank you for your advices

luki
  • 1,796
Balfar
  • 63

2 Answers2

1

You could use pgfplots to draw the axes and include the image with \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}

Output

luki
  • 1,796
0

Here is a basic setup you can adjust to your needs.

enter image description here

\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}

Sandy G
  • 42,558