将一个图的输出添加到另一个图

问题描述 投票:0回答:1

我想找到一种方法来转换底部图(从y = -20到0)并将其添加到上面的图(从y = 0-20到),以便最终域在y = 0到20之间:

enter image description here

但是,我在执行此操作时遇到了问题,因为我用来绘制底部图形(R12)的图形已经有一个负输入,因此它不会在y轴上显示。这是我的代码:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

N = 1001
lower = 0
upper = 20
u = np.linspace(lower, upper, N)
t1a, t3a = np.meshgrid(u,-u)
t1, t3 = np.meshgrid(u,u)
omega = 10
delta = 5
tau = 2
mu = 1
t2 = 0.1


def g(t):
    return delta * (omega ** 2) * (tau ** 2) * ((np.e ** (-t/tau))+(t/tau)-1)


R12 = 1 * (mu ** 4) * (np.e **(-1j * omega * (t3a-(t1a)))) * (np.e ** (-g(t1a)+g(t2)-g(t3a)-g(t1a+t2)-g(t2+t3a)+g(t1a+t2+t3a)))
R45 = 1 * (mu ** 4) * (np.e ** (-1j * omega * (t3+t1))) * (np.e ** (-g(t1)-g(t2)-g(t3)+g(t1+t2)+g(t2+t3)-g(t1+t2+t3)))
R12_fft = np.fft.fftshift((np.fft.fft2((R12)))) / np.sqrt(len(R12)) 
R45_fft = np.fft.fftshift((np.fft.fft2((R45)))) / np.sqrt(len(R45))
R_pure = (R12_fft + R45_fft)

plt.contourf(t1a,t3a,R12_fft, cmap = 'seismic')
plt.contourf(t1,t3,R45_fft, cmap = 'seismic')
plt.xlabel('${\omega}_{3}$', fontsize = 24)
plt.ylabel('${\omega}_{1}$', fontsize = 24)
plt.xlim(-20, 20)
plt.ylim(-20, 20)
plt.gca().set_aspect('equal', adjustable='box')
plt.colorbar()
plt.show()

例如,如果我尝试进行简单的添加:

plt.contourf(t1,t3,R_pure, cmap = 'seismic')

enter image description here

它基本上使我恢复了图形的相同形状。相反,我想将底部图形叠加到顶部,然后将输出加在一起。有什么办法可以实现?谢谢!

python contour
1个回答
0
投票

看起来像您要找的东西吗?

enter image description here

“相反,我想将底部图形叠加到顶部,然后将输出加在一起。”我真的不确定输出应该是什么样子以及您真正想要的是什么...

© www.soinside.com 2019 - 2024. All rights reserved.