|
1 | 1 | """ |
2 | | -====================================== |
3 | | -Projecting filled contour onto a graph |
4 | | -====================================== |
5 | | -
|
| 2 | +=================================== |
| 3 | +Project filled contour onto a graph |
| 4 | +=================================== |
6 | 5 | Demonstrates displaying a 3D surface while also projecting filled contour |
7 | 6 | 'profiles' onto the 'walls' of the graph. |
8 | | -
|
9 | | -See contour3d_demo2 for the unfilled version. |
| 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 import cm |
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, rstride=8, cstride=8, alpha=0.3) |
| 17 | +ax.plot_surface(X, Y, Z, edgecolor='royalblue', lw=0.5, rstride=8, cstride=8, |
| 18 | + alpha=0.3) |
21 | 19 |
|
22 | 20 | # Plot projections of the contours for each dimension. By choosing offsets |
23 | 21 | # that match the appropriate axes limits, the projected contours will sit on |
24 | 22 | # the 'walls' of the graph |
25 | | -ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm) |
26 | | -ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm) |
27 | | -ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm) |
| 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') |
28 | 26 |
|
29 | 27 | ax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100), |
30 | 28 | xlabel='X', ylabel='Y', zlabel='Z') |
|
0 commit comments