It seems weird that I cant find an answer to this question since this seems like something that is essential for a lot of plots, but how can I create an x and y axis for my plot?
This is a workaround that I use so far:
def f(x): return np.sin(x)
x = np.linspace(-2, 2, 1000)
plt.plot(x, f(x))
plt.plot(x, np.zeros_like(x))
plt.plot(np.zeros_like(x), x)
which produces:
What I would like is something like this:
What could I do to reproduce that? What I would like especially are the x and y axis numbering that is currently outside the plot (with matplotlib) to be on the x and y axis inside the plot, like on the image. Additionally I believe there should be an easier method to plot the x and y axis, instead of doing the hack that I do.
I've looked at a lot of matplotlib examples and can't find any example that contains what I want...