简体   繁体   中英

How to plot a 3d surface from multiple 2d arrays and one 1d array?

I am trying to plot the following data so it will look like the attached image: each text file is a 2X40 matrix.

xi,yi lines should be offset in the Z direction according the z array. I want to connect those line by a surface

z = np.array([0.5, 1, 1.5, 2, 2.5, 3, 3.3, 3.5, 4, 4.5, 5])

x0, y0 = np.loadtxt('Conv_Vd(Vk)_Vg=0.5.txt', delimiter='\t', unpack=True)
x1, y1 = np.loadtxt('Conv_Vd(Vk)_Vg=1.txt', delimiter='\t', unpack=True)
x2, y2 = np.loadtxt('Conv_Vd(Vk)_Vg=1.5.txt', delimiter='\t', unpack=True)
x3, y3 = np.loadtxt('Conv_Vd(Vk)_Vg=2.txt', delimiter='\t', unpack=True)
x4, y4 = np.loadtxt('Conv_Vd(Vk)_Vg=2.5.txt', delimiter='\t', unpack=True)
x5, y5 = np.loadtxt('Conv_Vd(Vk)_Vg=3.txt', delimiter='\t', unpack=True)
x6, y6 = np.loadtxt('Conv_Vd(Vk)_Vg=3.3.txt', delimiter='\t', unpack=True)
x7, y7 = np.loadtxt('Conv_Vd(Vk)_Vg=3.5.txt', delimiter='\t', unpack=True)
x8, y8 = np.loadtxt('Conv_Vd(Vk)_Vg=4.txt', delimiter='\t', unpack=True)
x9, y9 = np.loadtxt('Conv_Vd(Vk)_Vg=4.5.txt', delimiter='\t', unpack=True)
x10, y10 = np.loadtxt('Conv_Vd(Vk)_Vg=5.txt', delimiter='\t', unpack=True)

在此处输入图像描述

You want a 3D wireframe plot which means you need to coerce your data into an x,y,z format. Conventionally 'z' would be the dependent variable. Guessing at your current data structure, you have a bunch of sets of x,y where x is indepenent and y is the dependent. You then want to add a new 'depth' dimension which you are calling 'z'.

You need to end up with 3 1D arrays x,y,z. You can simply concatenate your existing x1,x2,x3..., y1,y2,y3... arrays, and create a 'z' array of the same final size, containing the z values you are prescribing. Then feed it all into plot_wireframe , remembering that you are swapping the y and z convention.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM