To put the origin in the center of the figure with matplotlib, there is the spines module, example:
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
x = np.linspace(-np.pi, np.pi, 100)
y = 2*np.sin(x)
ax = plt.gca()
ax.plot(x, y)
ax.grid(True)
ax.spines['left'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('zero')
ax.spines['top'].set_color('none')
plt.xlim(-np.pi,np.pi)
plt.savefig("CenterOriginMatplotlib01.png")
plt.show()
References
Links | Site |
---|---|
spines | matplotlib doc |
pylab_examples example code: spine_placement_demo.py | matplotlib |
Center origin in matplotlib | stackoverflow |
show origin axis (x,y) in matplotlib plot | stackoverflow |
change matplotlib axis settings | stackoverflow |
matplotlib.pyplot.gca(**kwargs) | matplotlib doc |