在python中我可以得到一个轮廓:
import numpy as np
import pylab as p
def main():
delta = 1
x = np.arange(-4.0, 4.0, delta)
y = np.arange(-4.0, 4.0, delta)
len_x, len_y = len(x), len(y)
z = np.random.rand(len_x, len_y)
cs = p.contour(x, y, z)
p.clabel(cs, inline=1, fontsize=10)
p.show()
if __name__ == '__main__':
main()
ss http://f.cl.ly/items/1Q412v053q3n293E2k2j/Captura_de_pantalla_072915_064801_PM.jpg
如何获取(x, y, z)
值列表的轮廓?
delta = 1
x = np.arange(-4.0, 4.0, delta)
y = np.arange(-4.0, 4.0, delta)
values = [(x0, y0, z0), (x1, y1, z1), (x3, y3, z3)]
cs = p.contour(x, y, values)
列表中的值很少,而不是len_x * len_y
答案 0 :(得分:1)
假设您只是试图找出如何使用contour()
列表提供values
:
p.contour(*zip(*values))
答案 1 :(得分:0)
我找到了这个解决方案
import numpy as np
import pylab as p
from matplotlib.mlab import griddata
def main():
p.figure()
x = [1, 1, 2, 2]
y = [1, 2, 1, 2]
z = [0.1, 0.2, 0.5, 0.2]
p.scatter(x, y, color='k')
# define grid.
xi = np.linspace(0, 3, 1000)
yi = np.linspace(0, 3, 1000)
zi = griddata(x, y, z, xi, yi, interp='nn')
cs = p.contour(xi, yi, zi, 10)
p.clabel(cs, inline=1, fontsize=12)
p.colorbar()
p.show()
if __name__ == '__main__':
main()
ss http://f.cl.ly/items/2H0i002G2v260I2r0O46/Captura_de_pantalla_073015_115325_AM.jpg