2

I am trying to draw Minkowski diagrams using tikz and got as far as below.

How do I align the origins of the two coordinate systems, i.e. how do I move up the B-system? I tried various things with the anchor option, which moved the system around, but I couldn't get it to where it is supposed to be.

\documentclass[a4paper]{article}

\usepackage{tikz,pgfplots,siunitx}

\begin{document}
    \begin{tikzpicture}
    
    \begin{axis}[
       black,
       anchor=south west,
       axis lines=center,
       xmin=0, xmax=14.9,
       ymin=-2.5,ymax=12.5,
       xtick distance=1,  %xticklabel={\empty},
       ytick distance=1,  %yticklabel={\empty},
       grid,
       x={1cm}, y={1cm},
       xlabel={$t_\mathrm{A}$ in \SI{e-8}{\second}}, ylabel={$x_\mathrm{A}$ in \SI{e-8}{\meter}},
       thick, every tick/.style={thick}
       ] 
      
       
      \end{axis}
    
    \begin{axis}[
       black,
       anchor=south west,
       axis lines=center,
       xmin=0,xmax=11.2,
       ymin=0,ymax=9.9,
       xtick distance=1, % xticklabel={\empty},
       ytick distance=1, % yticklabel={\empty},
       x={(1.25cm,0.75cm)}, y={(0.75cm,1.25cm)},
       xlabel={$t_\mathrm{B}$ in \SI{e-8}{\second}}, ylabel={$x_\mathrm{B}$ in \SI{e-8}{\meter}},
        xlabel style={right},
       thick, every tick/.style={thick},
       ]
      
    \end{axis}
    
    \end{tikzpicture}

\end{document}
4
  • 2
    anchor=origin for both? Possibly specifying the position with at={(x,y)} in addition? Commented Nov 6, 2021 at 22:58
  • Great! That simple. Somehow I only found north/south/east/west wherever I looked. Commented Nov 6, 2021 at 23:45
  • Why not look at the answer(by me), you already got!? tex.stackexchange.com/a/602012/8650 Commented Nov 7, 2021 at 0:02
  • 1
    @hpekristiansen Because in that answer it was center aligned, which works if both systems are symmetrical, which in this case here they are not. Commented Nov 7, 2021 at 0:11

1 Answer 1

1

The anchors of an axis are described in the pgfplots manual section 4.19 Alignment options, (page 374-75, in the manual for version 1.18.1).

For your case, add anchor=origin to both environments, which will place their origins at the same coordinate (or the coordinate specified by at={(<coordinate>)}).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .