Problem
I want to add an axis discontinuity on both my x
and y
axes, but doing so (even with just one axis) shifts my entire plot to the right.
MWE
Code
\documentclass[12pt, a4paper]{article}% Layout\usepackage[margin=2cm]{geometry}% Colour\usepackage[cmyk]{xcolor}% Graphing and math\usepackage{pgfplots}\pgfplotsset{% compat=1.18, axis lines=left, axis line style={semithick}, xlabel style={at=(current axis.right of origin), anchor=west}, ylabel style={at=(current axis.above origin), anchor=south east, rotate=-90, yshift=-1.5mm}, ticklabel style={font=\scriptsize}, clip mode=individual, width=6.8cm, anchor={outer north west}}\usetikzlibrary{decorations.pathreplacing, intersections}\usepgfplotslibrary{fillbetween}% Float placement\usepackage{float}% Dummy text\usepackage{lipsum}\title{\TeX{}.SE MWE}\author{BrightBulb123}\begin{document}\maketitle\section{Introduction}\lipsum[1]% Don't worry about the janky looking fill, it's just a modified test version. Although, if there was a way to hide it from clipping through the axis discontinuity lines, that would be greatly appreciated!\begin{figure}[H] \centering \begin{tikzpicture}[baseline] \begin{axis}[ title={Before tax}, xlabel={\( Q \)}, ylabel={\( P \)}, ymin=20, ymax=32, xmin=40, xmax=57, domain={0:\pgfkeysvalueof{/pgfplots/xmax}}, declare function={% supply(\P)=2.05*\P; }, axis y discontinuity=crunch % <--- Problematic for the plot ] \addplot[blue, thick, name path=supplycurve] ({supply(x)}, x) node[above right, pos=0.475, xshift=-3pt, yshift=4pt] {\( Q_S \)} node[blue!15!white, below right, pos=0.4075, xshift=3pt, yshift=-3pt, opacity=1, font=\tiny] {PS}; \node[] (equilibriumpoint) at (axis cs:50,25) {}; \path[name path=separator] (axis cs:\pgfkeysvalueof{/pgfplots/xmin},25) -- (equilibriumpoint); \draw[black, dashed, opacity=0.25] (axis cs:\pgfkeysvalueof{/pgfplots/xmin},25) -| (axis cs:50,\pgfkeysvalueof{/pgfplots/ymin}); \addplot[blue, fill opacity=0.15] fill between[of=separator and supplycurve, soft clip={domain=40:50}]; \end{axis} \end{tikzpicture}\end{figure}\end{document}