()
| 2211 | |
| 2212 | @image_comparison(['computed_zorder.png'], remove_text=True, style='mpl20') |
| 2213 | def test_computed_zorder(): |
| 2214 | plt.rcParams['axes3d.automargin'] = True # Remove when image is regenerated |
| 2215 | fig = plt.figure() |
| 2216 | ax1 = fig.add_subplot(221, projection='3d') |
| 2217 | ax2 = fig.add_subplot(222, projection='3d') |
| 2218 | ax2.computed_zorder = False |
| 2219 | |
| 2220 | # create a horizontal plane |
| 2221 | corners = ((0, 0, 0), (0, 5, 0), (5, 5, 0), (5, 0, 0)) |
| 2222 | for ax in (ax1, ax2): |
| 2223 | tri = art3d.Poly3DCollection([corners], |
| 2224 | facecolors='white', |
| 2225 | edgecolors='black', |
| 2226 | zorder=1) |
| 2227 | ax.add_collection3d(tri) |
| 2228 | |
| 2229 | # plot a vector |
| 2230 | ax.plot((2, 2), (2, 2), (0, 4), c='red', zorder=2) |
| 2231 | |
| 2232 | # plot some points |
| 2233 | ax.scatter((3, 3), (1, 3), (1, 3), c='red', zorder=10) |
| 2234 | |
| 2235 | ax.set_xlim(0, 5.0) |
| 2236 | ax.set_ylim(0, 5.0) |
| 2237 | ax.set_zlim(0, 2.5) |
| 2238 | |
| 2239 | ax3 = fig.add_subplot(223, projection='3d') |
| 2240 | ax4 = fig.add_subplot(224, projection='3d') |
| 2241 | ax4.computed_zorder = False |
| 2242 | |
| 2243 | dim = 10 |
| 2244 | X, Y = np.meshgrid((-dim, dim), (-dim, dim)) |
| 2245 | Z = np.zeros((2, 2)) |
| 2246 | |
| 2247 | angle = 0.5 |
| 2248 | X2, Y2 = np.meshgrid((-dim, dim), (0, dim)) |
| 2249 | Z2 = Y2 * angle |
| 2250 | X3, Y3 = np.meshgrid((-dim, dim), (-dim, 0)) |
| 2251 | Z3 = Y3 * angle |
| 2252 | |
| 2253 | r = 7 |
| 2254 | M = 1000 |
| 2255 | th = np.linspace(0, 2 * np.pi, M) |
| 2256 | x, y, z = r * np.cos(th), r * np.sin(th), angle * r * np.sin(th) |
| 2257 | for ax in (ax3, ax4): |
| 2258 | ax.plot_surface(X2, Y3, Z3, |
| 2259 | color='blue', |
| 2260 | alpha=0.5, |
| 2261 | linewidth=0, |
| 2262 | zorder=-1) |
| 2263 | ax.plot(x[y < 0], y[y < 0], z[y < 0], |
| 2264 | lw=5, |
| 2265 | linestyle='--', |
| 2266 | color='green', |
| 2267 | zorder=0) |
| 2268 | |
| 2269 | ax.plot_surface(X, Y, Z, |
| 2270 | color='red', |
nothing calls this directly
no test coverage detected
searching dependent graphs…