I am facing difficulty while plotting my 3d data using wireframe, please help. It is working in plot3D but not in wireframe.
Python code is given here.
from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt
import csv
file="xyz.dat"
x=[]
y=[]
z=[]
with open(file,'r') as csvfile:
data = csv.reader(csvfile, delimiter=' ')
for row in data:
if(row):
x.append(row[0])
y.append(row[1])
z.append(row[2])
x = map(float,x)
y = map(float,y)
z = map(float,z)
fig = plt.figure()
ax = plt.axes(projection ='3d')
#ax.plot3D(x, y, z, color = 'green')
ax.plot_wireframe(x, y, z, color = 'green')
plt.show()
0 0 0
0 1 0
0 2 0
1 0 10
1 1 10
1 2 10
2 0 10
2 1 10
2 2 10
3 0 10
3 1 10
3 2 10
4 0 50
4 1 50
4 2 50
6 0 50
6 1 50
6 2 50
7 0 90
7 1 90
7 2 90
9 0 90
9 1 90
9 2 90
Yes, I got it.
from mpl_toolkits import mplot3d
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import csv
file="xyz.txt"
x=[]
y=[]
z=[]
with open(file,'r') as csvfile:
data = csv.reader(csvfile, delimiter=' ')
for row in data:
if(row):
x.append(row[0])
y.append(row[1])
z.append(row[2])
x = map(float,x)
y = map(float,y)
z = map(float,z)
X,Y = np.meshgrid(x,y)
Z = griddata((x,y),z,(X,Y),method='linear')
fig = plt.figure()
ax = plt.axes(projection ='3d')
ax.plot_wireframe(X, Y, Z, color = 'green')
plt.show()
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.