|
28 | 28 | yy = x*np.sin(theta) + y*np.cos(theta) # rotate y by -theta |
29 | 29 |
|
30 | 30 | # Plot the rasterized and non-rasterized plot |
31 | | -fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2) |
| 31 | +fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, constrained_layout=True) |
32 | 32 |
|
33 | 33 | # Create a pseudocolor non-rastertized plot with a non-regular rectangular grid |
34 | 34 | ax1.set_aspect(1) |
|
38 | 38 | # Create a pseudocolor rastertized plot with a non-regular rectangular grid |
39 | 39 | ax2.set_aspect(1) |
40 | 40 | ax2.set_title("Rasterization") |
41 | | -m = ax2.pcolormesh(xx, yy, d) |
42 | | -# Force rasterized drawing in vector backend output |
43 | | -m.set_rasterized(True) |
| 41 | +m = ax2.pcolormesh(xx, yy, d, rasterized=True) |
44 | 42 |
|
45 | 43 | # Create a pseudocolor non-rastertized plot with a non-regular rectangular |
46 | 44 | # grid and an overlapped "Text" |
|
53 | 51 | # Create a pseudocolor rastertized plot with a non-regular rectangular |
54 | 52 | # grid and an overlapped "Text" |
55 | 53 | ax4.set_aspect(1) |
56 | | -m = ax4.pcolormesh(xx, yy, d) |
57 | | -m.set_zorder(-20) |
58 | | -ax4.text(0.5, 0.5, "Text", alpha=0.2, |
59 | | - zorder=-15, |
| 54 | +m = ax4.pcolormesh(xx, yy, d, zorder=-20) |
| 55 | +ax4.text(0.5, 0.5, "Text", alpha=0.2, zorder=-15, |
60 | 56 | va="center", ha="center", size=50, transform=ax4.transAxes) |
61 | 57 | # Set zorder value below which artists will be rasterized |
62 | 58 | ax4.set_rasterization_zorder(-10) |
|
0 commit comments