0

With the axis enviroment in TikZ, how can I make the "shortened" horisontal axis? TIA. enter image description here

mf67
  • 666
  • 2
    That's commonly called "broken axis" (this is why you couldn't find it by searching). Ther is no native possibility, but you can see https://tex.stackexchange.com/questions/283741/axis-break-in-pgfplots-same-scaling-for-the-two-plots (in y direction) or https://tex.stackexchange.com/questions/149081/collapse-range-in-x-axis-with-pgfplots-break-x-axis (along x) – Rmano Apr 23 '22 at 11:49
  • 1
    @Rmano Given that this is at the start of the axis with no data to the left of the discontinuity, doesn't axis x discontinuity=crunch do exactly what the OP for? – Torbjørn T. Apr 23 '22 at 16:03
  • @TorbjørnT. I just discoved that option ;-) ... Thanks! – Rmano Apr 23 '22 at 18:31

1 Answers1

4

You can use the axis x discontinuity option (as also suggested in the comments):

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document} \begin{tikzpicture} \begin{axis}[ thick, axis lines=left, axis x discontinuity=crunch, ticks=none, xmin=0.8, xmax=2.2, ymin=-0.2, ymax=1, ] \addplot[thick,domain=1:2] {ln(x)}; \end{axis} \end{tikzpicture} \end{document}

enter image description here