我想知道在两组轮廓线之间找到所有交点(到舍入误差)的最佳方法.这是最好的方法吗?这是一个例子:
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-1,1,500)
X,Y = np.meshgrid(x,x)
Z1 = np.abs(np.sin(2*X**2+Y))
Z2 = np.abs(np.cos(2*Y**2+X**2))
plt.contour(Z1,colors='k')
plt.contour(Z2,colors='r')
plt.show()
Run Code Online (Sandbox Code Playgroud)

我想要一些类似的:
intersection_points = intersect(contour1,contour2)
print intersection_points
[(x1,y1),...,(xn,yn)]
Run Code Online (Sandbox Code Playgroud) 关于在 matplotlib 中的子图中嵌入小图的帖子,我正在研究这个解决方案,但由于某种原因,转换被忽略了!
我错了吗?还是有bug?
import matplotlib.pyplot as plt
import numpy as np
axes = []
x = np.linspace(-np.pi,np.pi)
fig = plt.figure(figsize=(10,10))
subpos = (0,0.6)
for i in range(4):
axes.append(fig.add_subplot(2,2,i))
for axis in axes:
axis.set_xlim(-np.pi,np.pi)
axis.set_ylim(-1,3)
axis.plot(x,np.sin(x))
fig.add_axes([0.5,0.5,0.1,0.1],transform=axis.transAxes)
plt.show()
Run Code Online (Sandbox Code Playgroud) 我有两个清单:
list1 = ['a','b','c']
list2 = ['1','2','3','4','5']
Run Code Online (Sandbox Code Playgroud)
我想列出清单:
list3 = [('1','a'),('2','b'),('3','c'),('4','a'),('5','b')]
Run Code Online (Sandbox Code Playgroud)
换句话说,在它们之间进行循环组合.所以,我的问题是:哪种方式更有效?