簡體   English   中英

Matplotlib 向左移動繪圖圖

[英]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()

pyh

我想讓 x 刻度保持不變,但想要移動圖形,以便圖形的起點在 y 軸上。 有什么建議?

先感謝您。

您可以通過更改 x 軸上的限制使線的起點位於 y 軸上

ax.set_xlim(xmin=0)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM