diffracteD
2015-05-06 06:19:28 UTC
Hi.
I am using matplotlib to plot a wireframe over a 3D list data I have.
X = [2.06, 2.07, 2.14, 2.09, 2.2, 2.05, 1.92, 2.06, 2.11, 2.07, 2.15, 2.29,
2.06, 2.09, 2.19, 2.19, 2.26, 2.15, 2.15, 2.06, 2.29, 2.27, 2.46, 2.2,
2.01, 2.11, 2.03, 2.1, 2.17, 2.1]
Y = [171.82, 170.8, 159.59, 164.28, 169.98, 162.23, 167.37, 173.81, 166.66,
155.13, 156.56, 156.78, 158.15, 163.31, 150.97, 133.91, 142.36, 152.48,
138.6, 153.88, 155.13, 146.09, 147.84, 167.9, 161.82, 168.39, 163.73,
164.03, 169.33, 159.42]
Z = [-1.41173660883, -1.26977354468, -1.07436015752, -1.07522326036,
-1.46114949754, -0.955999769503, -0.0826570511052, -1.25171489428,
-1.2005961876, -0.862264432276, -1.27266152624, -1.55152901892,
-0.939999658603, -1.2470594709, 0.40793102312, -1.5375122067,
-1.02404937182, -1.38113558714, -0.842054259969, -0.908694881796,
-1.57965851609, -1.35631827259, -2.0568110654, -0.783657274668,
-0.329844805297, -1.37033049146, -0.853410578988, -1.47048937914,
-1.65570962873, -1.21419612238]
I am trying to plot it using:
`
*data = np.c_[cumualtive_dist,cumulative_ang,cumulative_energ]
# regular grid covering the domain of the data...
mn = np.min(data, axis=0)
mx = np.max(data, axis=0)
X,Y = np.meshgrid(np.linspace(mn[0], mx[0], 50), np.linspace(mn[1],
mx[1], 50))
XX = X.flatten()
YY = Y.flatten()
# best-fit quadratic curve
A = np.c_[np.ones(data.shape[0]), data[:,:2], np.prod(data[:,:2],
axis=1), data[:,:2]**2]
C,_,_,_ = scipy.linalg.lstsq(A, data[:,2])
# evaluate it on a grid
Z = np.dot(np.c_[np.ones(XX.shape), XX, YY, XX*YY, XX**2, YY**2],
C).reshape(X.shape)
# Plot scatter-points and fitted 3D surface
#-----------------------------------------
fig3 = plt.figure(figsize=(10,6))
ax3 = fig3.gca(projection='3d')
surf = ax3.plot_surface(X, Y, Z, rstride=1, cstride=1, alpha=0.5,
cmap=cm.jet)
#Adding a color-bar...
fig3.colorbar(surf, shrink=0.6, aspect=6)
#ax3.plot_wireframe(X, Y, Z, rstride=1, cstride=1, alpha=0.4)
ax3.scatter(data[:,0], data[:,1], data[:,2], c='r', s=5)
ax3.set_zlim3d(-5, 5) #Limiting Z-axis... *
`
This code is giving a plot looks like(shown below):
<Loading Image...>
But I was looking for a fitted-graph somewhat-looks like(however not
exactly) this:
<Loading Image...>
I mean the stretching-of-thread appearance w.r.t. distribution of points,
I'm not being able to get such things in mine.
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/issue-with-wireframe-plot-tp45474.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
I am using matplotlib to plot a wireframe over a 3D list data I have.
X = [2.06, 2.07, 2.14, 2.09, 2.2, 2.05, 1.92, 2.06, 2.11, 2.07, 2.15, 2.29,
2.06, 2.09, 2.19, 2.19, 2.26, 2.15, 2.15, 2.06, 2.29, 2.27, 2.46, 2.2,
2.01, 2.11, 2.03, 2.1, 2.17, 2.1]
Y = [171.82, 170.8, 159.59, 164.28, 169.98, 162.23, 167.37, 173.81, 166.66,
155.13, 156.56, 156.78, 158.15, 163.31, 150.97, 133.91, 142.36, 152.48,
138.6, 153.88, 155.13, 146.09, 147.84, 167.9, 161.82, 168.39, 163.73,
164.03, 169.33, 159.42]
Z = [-1.41173660883, -1.26977354468, -1.07436015752, -1.07522326036,
-1.46114949754, -0.955999769503, -0.0826570511052, -1.25171489428,
-1.2005961876, -0.862264432276, -1.27266152624, -1.55152901892,
-0.939999658603, -1.2470594709, 0.40793102312, -1.5375122067,
-1.02404937182, -1.38113558714, -0.842054259969, -0.908694881796,
-1.57965851609, -1.35631827259, -2.0568110654, -0.783657274668,
-0.329844805297, -1.37033049146, -0.853410578988, -1.47048937914,
-1.65570962873, -1.21419612238]
I am trying to plot it using:
`
*data = np.c_[cumualtive_dist,cumulative_ang,cumulative_energ]
# regular grid covering the domain of the data...
mn = np.min(data, axis=0)
mx = np.max(data, axis=0)
X,Y = np.meshgrid(np.linspace(mn[0], mx[0], 50), np.linspace(mn[1],
mx[1], 50))
XX = X.flatten()
YY = Y.flatten()
# best-fit quadratic curve
A = np.c_[np.ones(data.shape[0]), data[:,:2], np.prod(data[:,:2],
axis=1), data[:,:2]**2]
C,_,_,_ = scipy.linalg.lstsq(A, data[:,2])
# evaluate it on a grid
Z = np.dot(np.c_[np.ones(XX.shape), XX, YY, XX*YY, XX**2, YY**2],
C).reshape(X.shape)
# Plot scatter-points and fitted 3D surface
#-----------------------------------------
fig3 = plt.figure(figsize=(10,6))
ax3 = fig3.gca(projection='3d')
surf = ax3.plot_surface(X, Y, Z, rstride=1, cstride=1, alpha=0.5,
cmap=cm.jet)
#Adding a color-bar...
fig3.colorbar(surf, shrink=0.6, aspect=6)
#ax3.plot_wireframe(X, Y, Z, rstride=1, cstride=1, alpha=0.4)
ax3.scatter(data[:,0], data[:,1], data[:,2], c='r', s=5)
ax3.set_zlim3d(-5, 5) #Limiting Z-axis... *
`
This code is giving a plot looks like(shown below):
<Loading Image...>
But I was looking for a fitted-graph somewhat-looks like(however not
exactly) this:
<Loading Image...>
I mean the stretching-of-thread appearance w.r.t. distribution of points,
I'm not being able to get such things in mine.
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/issue-with-wireframe-plot-tp45474.html
Sent from the matplotlib - users mailing list archive at Nabble.com.