[英]Matplotlib shift plot graph to left
我想知道是否可以将图形仅向左移动以用于下图。
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.