Skip to content

Commit 13e0c0b

Browse files
author
Onur R. Bingol
committed
Reorganize and update surface visualization examples
1 parent 0fbfb06 commit 13e0c0b

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
lines changed

visualization/mpl_scatter_wframe.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@
2323
cpgrid = np.genfromtxt('../surface/ctrlpts03_orig.csv', delimiter=',', skip_header=1, names=['x', 'y', 'z'])
2424
surf = np.genfromtxt('../surface/surfpts03_orig.csv', delimiter=',', skip_header=1, names=['x', 'y', 'z'])
2525

26-
# Reshape surface points array for plotting, @ref: https://stackoverflow.com/a/21352257
27-
cols = surf['x'].shape[0]
28-
X = surf['x'].reshape(-1, cols)
29-
Y = surf['y'].reshape(-1, cols)
30-
Z = surf['z'].reshape(-1, cols)
31-
3226
# Start plotting of the surface and the control points grid
3327
fig = plt.figure(figsize=(10.67, 8), dpi=96)
3428
ax = fig.gca(projection='3d')
@@ -37,17 +31,17 @@
3731
ax.scatter(cpgrid['x'], cpgrid['y'], cpgrid['z'], color='blue', s=50, depthshade=True)
3832

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

4236
# Set axis limits
4337
ax.set_xlim(-1, 1)
4438
ax.set_ylim(-1, 1)
4539
ax.set_zlim(0, 1)
4640

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

5246
# Display the 3D plot
5347
plt.show()

visualization/mpl_wframe_trisurf.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
surf = np.genfromtxt('../surface/surfpts02_orig.csv', delimiter=',', skip_header=1, names=['x', 'y', 'z'])
2727

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

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

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

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

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

5756
# Display the 3D plot
5857
plt.show()

visualization/mpl_wframe_wframe.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
surf = np.genfromtxt('../surface/surfpts01_orig.csv', delimiter=',', skip_header=1, names=['x', 'y', 'z'])
2525

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

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

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

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

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

5454
# Display the 3D plot
5555
plt.show()

0 commit comments

Comments
 (0)