| 79 | |
| 80 | |
| 81 | def test_composite_image(): |
| 82 | # Test that figures can be saved with and without combining multiple images |
| 83 | # (on a single set of axes) into a single composite image. |
| 84 | X, Y = np.meshgrid(np.arange(-5, 5, 1), np.arange(-5, 5, 1)) |
| 85 | Z = np.sin(Y ** 2) |
| 86 | fig, ax = plt.subplots() |
| 87 | ax.set_xlim(0, 3) |
| 88 | ax.imshow(Z, extent=[0, 1, 0, 1]) |
| 89 | ax.imshow(Z[::-1], extent=[2, 3, 0, 1]) |
| 90 | plt.rcParams['image.composite_image'] = True |
| 91 | with PdfPages(io.BytesIO()) as pdf: |
| 92 | fig.savefig(pdf, format="pdf") |
| 93 | assert len(pdf._file._images) == 1 |
| 94 | plt.rcParams['image.composite_image'] = False |
| 95 | with PdfPages(io.BytesIO()) as pdf: |
| 96 | fig.savefig(pdf, format="pdf") |
| 97 | assert len(pdf._file._images) == 2 |
| 98 | |
| 99 | |
| 100 | def test_indexed_image(): |