Adding Arrowheads strikes the y-axis 0 label

Hi,
I am trying to add arrowheads to the end of my x- and y-axis. When doing so, the xaxis strikes through the 0 label tick of the yaxis, see also the attached image.
Is there a possibility that I can maybe cut down the length of the xaxis? I would rather not want to remove the ytick in any way.

Thank you very much in advance!

Code for Reproducing

import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.axisartist.axislines import AxesZero

nrows, ncols = 1, 1
fig = plt.figure()
gs = gridspec.GridSpec(nrows, ncols, figure=fig)
ax = fig.add_subplot(gs[0, 0], axes_class=AxesZero)

x = np.linspace(0, 5)
y = np.sin(x)
ax.plot(x, y)

for direction in ["xzero", "yzero"]:
    # adds arrows at the ends of each axis
    ax.axis[direction].set_axisline_style("-|>")

    # adds X and Y-axis from the origin
    ax.axis[direction].set_visible(True)
for direction in ["left", "right", "bottom", "top"]:
    # hides borders
    ax.axis[direction].set_visible(False)

plt.show()

Actual Outcome

Link to Github Issue

[Bug]: x-axis strikes y-axis zero · Issue #23301 · matplotlib/matplotlib (github.com)

Thanks for moving this here, and welcome!

I’m still to following what you are after here - do you want the xaxis to start further to the right?

You may find Spine Placement — Matplotlib 3.5.2 documentation useful?

I think this is exactly what I need, however, I do not really understand the spline API. I want the spline to start at (0,0) so it does not go any further.

Thank you very much for your help!

Then you just set the xlim of the axes: ax.set_xlim(0, 6)

1 Like

As simple as a solution can be, thank you very much!