Python Matplotlib向左移动打印图

Python Matplotlib向左移动打印图,python,django,matplotlib,plot,graph,Python,Django,Matplotlib,Plot,Graph,我想知道,对于下面的绘图图,是否可以只向左移动图形 import matplotlib import matplotlib.pyplot as plt import numpy as np # Data for plotting t = np.arange(0.0, 2.0, 0.01) s = 1 + np.sin(2 * np.pi * t) fig, ax = plt.subplots() ax.plot(t, s) ax.set(xlabel='time (s)', ylabel=

我想知道,对于下面的绘图图,是否可以只向左移动图形

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)

fig, ax = plt.subplots()
ax.plot(t, s)

ax.set(xlabel='time (s)', ylabel='voltage (mV)',
   title='About as simple as it gets, folks')
ax.grid()

fig.savefig("test.png")
plt.show()

我想让x记号保持不变,但要移动图形,使图形的起点位于y轴上。 有什么建议吗


提前谢谢。

您可以通过使用更改x轴上的限制,使线的起点位于y轴上

ax.set_xlim(xmin=0)

plt.xlim(t.min(),t.max())
ax.autoscale(enable=True,axis='x',tight=True)
如?plt.autoscale(enable=True,axis='x',tight=True)是的,它对我有用,但我决定用autoscale哈哈,非常感谢