Matplotlib向左移动绘图图

时间:2020-03-17 23:31:14

标签: 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='voltage (mV)',
   title='About as simple as it gets, folks')
ax.grid()

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

Pyh

我想使x刻度保持不变,但想移动图形,以使图形的起点在y轴上。 有什么建议吗?

谢谢。

1 个答案:

答案 0 :(得分:1)

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

ax.set_xlim(xmin=0)