I'm making a plot with an x-axis break // using different size subplots as described in
CodePudding user response:
You need to introduce a factor f
taking into account the different axis scales:
d = .015 # how big to make the diagonal lines in axes coordinates
f = (np.diff(ax1.get_xlim()) / np.diff(ax2.get_xlim())).item()
# arguments to pass plot, just so we don't keep repeating them
kwargs = dict(transform=ax1.transAxes, color='k', clip_on=False)
ax1.plot((1-d*f,1 d*f), (-d, d), **kwargs)
ax1.plot((1-d*f,1 d*f),(1-d,1 d), **kwargs)
kwargs.update(transform=ax2.transAxes) # switch to the bottom axes
ax2.plot((-d, d), (1-d,1 d), **kwargs)
ax2.plot((-d, d), (-d, d), **kwargs)
Update:
An easier way is to use the approach shown in the official