简体   繁体   English

Matplotlib 向左移动绘图图

[英]Matplotlib shift plot graph to left

I'm wondering if it is possible to shift the graph only to the left for the following 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

I want to leave the x ticks the same but want to shift the graph so that the starting point of the graph is on y-axis.我想让 x 刻度保持不变,但想要移动图形,以便图形的起点在 y 轴上。 Any suggestions?有什么建议?

Thank you in advance.先感谢您。

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

ax.set_xlim(xmin=0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM