我试图绘制两个形状不同的数组,但无法将其中一个投影到另一个的顶部。例如:
#importing the relevant packages
import numpy as np
import matplotlib.pyplot as plt
def overplot(data1,data2):
'''
This function should make a contour plot
of data2 over the data1 plot.
'''
#creating the figure
fig = plt.figure()
#adding an axe
ax = fig.add_axes([1,1,1,1])
#making the plot for the
#first dataset
ax.imshow(data1)
#overplotting the contours
#for the second dataset
ax.contour(data2, projection = data2,
levels = [0.5,0.7])
#showing the figure
plt.show(fig)
return
if __name__ == '__main__':
'''
testing zone
'''
#creating two mock datasets
data1 = np.random.rand(3,3)
data2 = np.random.rand(9,9)
#using the overplot
overplot(data1,data2)
当前,我的输出如下:
我实际上想要将第二个数据集的轮廓投影到第一个数据集中。这样,如果我得到的是同一物体的图像,但相机的分辨率不同,则可以绘制这些图。我怎样才能做到这一点?
感谢您的时间和精力。