簡體   English   中英

matplotlib 放大 plot window 在主 Z32FA6E1B78A9D4028953E60564A2AA4Z 內

[英]matplotlib zoomed plot window inside a main plot?

我正在嘗試 plot 放大 plot 里面的主要 plot。 我成功地運行了代碼並獲得了繪圖。 但是沒有放大。

我的代碼:

# create some data to use for the plot
dt = 0.001
t = np.arange(0.0, 10.0, dt)
r = np.exp(-t[:10]/0.05)               # impulse response
x = np.random.randn(len(t))
s = np.convolve(x, r)[:len(x)]*dt  # colored noise

# the main axes is subplot(111) by default
plt.plot(t, s)

# this is another inset axes over the main axes
a = plt.axes([0.2, 0.6, .2, .2])
plt.plot(t[:len(r)], r)
plt.xlim(0, 0.2)
plt.xticks([])
plt.yticks([])
plt.show()

目前output: 在此處輸入圖像描述

所以這段代碼:

dt = 0.001
t = np.arange(0.0, 10.0, dt)
r = np.exp(-t[:10]/0.05)
x = np.random.randn(len(t))
s = np.convolve(x, r)[:len(x)] * dt

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

inset_ax = ax.inset_axes([0.2, 0.6, 0.2, 0.2])
inset_ax.plot(t[:len(r)], r)

生產:
插圖

至關重要的是, t[:len(r)]min / max分別為0 / 0.009 因此,您應用的xlim似乎是使它看起來沒有“縮放”的原因

暫無
暫無

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

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