Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff7c43a

Browse files
committed
Specifying the color map and the edge color as strings
1 parent 85e6634 commit ff7c43a

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

examples/mplot3d/contour3d_3.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,27 @@
22
=====================================
33
Project contour profiles onto a graph
44
=====================================
5-
65
Demonstrates displaying a 3D surface while also projecting contour 'profiles'
76
onto the 'walls' of the graph.
8-
97
See :doc:`contourf3d_2` for the filled version.
108
"""
119

1210
from mpl_toolkits.mplot3d import axes3d
1311
import matplotlib.pyplot as plt
14-
from matplotlib.cm import coolwarm as cmap
1512

1613
ax = plt.figure().add_subplot(projection='3d')
1714
X, Y, Z = axes3d.get_test_data(0.05)
1815

1916
# Plot the 3D surface
20-
ax.plot_surface(X, Y, Z, edgecolor=cmap(0), lw=0.5, rstride=8, cstride=8,
17+
ax.plot_surface(X, Y, Z, edgecolor='royalblue', lw=0.5, rstride=8, cstride=8,
2118
alpha=0.3)
2219

2320
# Plot projections of the contours for each dimension. By choosing offsets
2421
# that match the appropriate axes limits, the projected contours will sit on
2522
# the 'walls' of the graph.
26-
ax.contour(X, Y, Z, zdir='z', offset=-100, cmap=cmap)
27-
ax.contour(X, Y, Z, zdir='x', offset=-40, cmap=cmap)
28-
ax.contour(X, Y, Z, zdir='y', offset=40, cmap=cmap)
23+
ax.contour(X, Y, Z, zdir='z', offset=-100, cmap='coolwarm')
24+
ax.contour(X, Y, Z, zdir='x', offset=-40, cmap='coolwarm')
25+
ax.contour(X, Y, Z, zdir='y', offset=40, cmap='coolwarm')
2926

3027
ax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100),
3128
xlabel='X', ylabel='Y', zlabel='Z')

examples/mplot3d/contourf3d_2.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,27 @@
22
===================================
33
Project filled contour onto a graph
44
===================================
5-
65
Demonstrates displaying a 3D surface while also projecting filled contour
76
'profiles' onto the 'walls' of the graph.
8-
97
See :doc:`contour3d_3` for the unfilled version.
108
"""
119

1210
from mpl_toolkits.mplot3d import axes3d
1311
import matplotlib.pyplot as plt
14-
from matplotlib.cm import coolwarm as cmap
1512

1613
ax = plt.figure().add_subplot(projection='3d')
1714
X, Y, Z = axes3d.get_test_data(0.05)
1815

1916
# Plot the 3D surface
20-
ax.plot_surface(X, Y, Z, edgecolor=cmap(0), lw=0.5, rstride=8, cstride=8,
17+
ax.plot_surface(X, Y, Z, edgecolor='royalblue', lw=0.5, rstride=8, cstride=8,
2118
alpha=0.3)
2219

2320
# Plot projections of the contours for each dimension. By choosing offsets
2421
# that match the appropriate axes limits, the projected contours will sit on
2522
# the 'walls' of the graph
26-
ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cmap)
27-
ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cmap)
28-
ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cmap)
23+
ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap='coolwarm')
24+
ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap='coolwarm')
25+
ax.contourf(X, Y, Z, zdir='y', offset=40, cmap='coolwarm')
2926

3027
ax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100),
3128
xlabel='X', ylabel='Y', zlabel='Z')

0 commit comments

Comments
 (0)