Skip to content

Commit

Permalink
Reorganize and update surface visualization examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Onur R. Bingol committed Jan 21, 2018
1 parent 0fbfb06 commit 13e0c0b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
14 changes: 4 additions & 10 deletions visualization/mpl_scatter_wframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
cpgrid = np.genfromtxt('../surface/ctrlpts03_orig.csv', delimiter=',', skip_header=1, names=['x', 'y', 'z'])
surf = np.genfromtxt('../surface/surfpts03_orig.csv', delimiter=',', skip_header=1, names=['x', 'y', 'z'])

# Reshape surface points array for plotting, @ref: https://stackoverflow.com/a/21352257
cols = surf['x'].shape[0]
X = surf['x'].reshape(-1, cols)
Y = surf['y'].reshape(-1, cols)
Z = surf['z'].reshape(-1, cols)

# Start plotting of the surface and the control points grid
fig = plt.figure(figsize=(10.67, 8), dpi=96)
ax = fig.gca(projection='3d')
Expand All @@ -37,17 +31,17 @@
ax.scatter(cpgrid['x'], cpgrid['y'], cpgrid['z'], color='blue', s=50, depthshade=True)

# Surface points as a wireframe plot (use mode='wireframe' while saving CSV file)
ax.plot_wireframe(X, Y, Z, color='green')
ax.plot(surf['x'], surf['y'], surf['z'], color='green')

# Set axis limits
ax.set_xlim(-1, 1)
ax.set_ylim(-1, 1)
ax.set_zlim(0, 1)

# Add legend to 3D plot, @ref: https://stackoverflow.com/a/20505720
scatter1_proxy = matplotlib.lines.Line2D([0], [0], linestyle='none', color='blue', marker='o')
scatter2_proxy = matplotlib.lines.Line2D([0], [0], linestyle='none', color='green', marker='o')
ax.legend([scatter1_proxy, scatter2_proxy], ['Control Points', 'Surface Wireframe'], numpoints=1)
plot1_proxy = matplotlib.lines.Line2D([0], [0], linestyle='none', color='blue', marker='o')
plot2_proxy = matplotlib.lines.Line2D([0], [0], linestyle='none', color='green', marker='o')
ax.legend([plot1_proxy, plot2_proxy], ['Control Points Grid', 'Surface Plot'], numpoints=1)

# Display the 3D plot
plt.show()
15 changes: 7 additions & 8 deletions visualization/mpl_wframe_trisurf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
surf = np.genfromtxt('../surface/surfpts02_orig.csv', delimiter=',', skip_header=1, names=['x', 'y', 'z'])

# Arrange control points grid for plotting, @ref: https://stackoverflow.com/a/21352257
cols = cpgrid['x'].shape[0]
Xc = cpgrid['x'].reshape(-1, cols)
Yc = cpgrid['y'].reshape(-1, cols)
Zc = cpgrid['z'].reshape(-1, cols)
Xc = cpgrid['x']
Yc = cpgrid['y']
Zc = cpgrid['z']

# Arrange surface points array for plotting
X = surf['x']
Expand All @@ -44,15 +43,15 @@
ax = fig.gca(projection='3d')

# Control points as a scatter plot (use mode='wireframe' while saving CSV file)
ax.plot_wireframe(Xc, Yc, Zc, color=colors[0])
ax.plot(Xc, Yc, Zc, color=colors[0], linestyle='-.', marker='o', markerfacecolor='orange', markersize=5)

# Surface points as a triangulated surface plot (use mode='linear' while saving CSV file)
ax.plot_trisurf(X, Y, Z, cmap=cm.winter)

# Add legend to 3D plot, @ref: https://stackoverflow.com/a/20505720
scatter1_proxy = matplotlib.lines.Line2D([0], [0], linestyle='none', color=colors[0], marker='o')
scatter2_proxy = matplotlib.lines.Line2D([0], [0], linestyle='none', color=colors[1], marker='^')
ax.legend([scatter1_proxy, scatter2_proxy], ['Control Grid', 'Surface Triplot'], numpoints=1)
plot1_proxy = matplotlib.lines.Line2D([0], [0], linestyle='-.', color=colors[0], marker='o')
plot2_proxy = matplotlib.lines.Line2D([0], [0], linestyle='none', color=colors[1], marker='^')
ax.legend([plot1_proxy, plot2_proxy], ['Control Points Grid', 'Surface Plot'], numpoints=1)

# Display the 3D plot
plt.show()
14 changes: 7 additions & 7 deletions visualization/mpl_wframe_wframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
surf = np.genfromtxt('../surface/surfpts01_orig.csv', delimiter=',', skip_header=1, names=['x', 'y', 'z'])

# Arrange control points grid for plotting, @ref: https://stackoverflow.com/a/21352257
Xc = cpgrid['x'].reshape(-1, cpgrid['x'].shape[0])
Yc = cpgrid['y'].reshape(-1, cpgrid['x'].shape[0])
Zc = cpgrid['z'].reshape(-1, cpgrid['x'].shape[0])
Xc = cpgrid['x']
Yc = cpgrid['y']
Zc = cpgrid['z']

# Arrange surface points array for plotting, @ref: https://stackoverflow.com/a/21352257
X = surf['x'].reshape(-1, surf['x'].shape[0])
Expand All @@ -41,15 +41,15 @@
ax = fig.gca(projection='3d')

# Control points as a wireframe plot (use mode='wireframe' while saving CSV file)
ax.plot_wireframe(Xc, Yc, Zc, color=colors[0])
ax.plot(Xc, Yc, Zc, color=colors[0], linestyle='-.', marker='o', markerfacecolor='orange', markersize=5)

# Surface points as a wireframe plot (use mode='wireframe' while saving CSV file)
ax.plot_wireframe(X, Y, Z, color=colors[1])

# Add legend to 3D plot, @ref: https://stackoverflow.com/a/20505720
plot1_proxy = matplotlib.lines.Line2D([0], [0], linestyle='none', color=colors[0], marker='o')
plot2_proxy = matplotlib.lines.Line2D([0], [0], linestyle='none', color=colors[1], marker='o')
ax.legend([plot1_proxy, plot2_proxy], ['Control Points', 'Surface'], numpoints=1)
plot1_proxy = matplotlib.lines.Line2D([0], [0], linestyle='-.', color=colors[0], marker='o')
plot2_proxy = matplotlib.lines.Line2D([0], [0], linestyle='none', color=colors[1], marker='^')
ax.legend([plot1_proxy, plot2_proxy], ['Control Points Grid', 'Surface Plot'], numpoints=1)

# Display the 3D plot
plt.show()

0 comments on commit 13e0c0b

Please sign in to comment.