|
2 | 2 | =================================== |
3 | 3 | Project filled contour onto a graph |
4 | 4 | =================================== |
5 | | -
|
6 | 5 | Demonstrates displaying a 3D surface while also projecting filled contour |
7 | 6 | 'profiles' onto the 'walls' of the graph. |
8 | | -
|
9 | 7 | See :doc:`contour3d_3` for the unfilled version. |
10 | 8 | """ |
11 | 9 |
|
12 | 10 | from mpl_toolkits.mplot3d import axes3d |
13 | 11 | import matplotlib.pyplot as plt |
14 | | -from matplotlib.cm import coolwarm as cmap |
15 | 12 |
|
16 | 13 | ax = plt.figure().add_subplot(projection='3d') |
17 | 14 | X, Y, Z = axes3d.get_test_data(0.05) |
18 | 15 |
|
19 | 16 | # 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, |
21 | 18 | alpha=0.3) |
22 | 19 |
|
23 | 20 | # Plot projections of the contours for each dimension. By choosing offsets |
24 | 21 | # that match the appropriate axes limits, the projected contours will sit on |
25 | 22 | # 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') |
29 | 26 |
|
30 | 27 | ax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100), |
31 | 28 | xlabel='X', ylabel='Y', zlabel='Z') |
|
0 commit comments