|
31 | 31 | import matplotlib.pyplot as plt
|
32 | 32 | from matplotlib.colors import LogNorm
|
33 | 33 |
|
34 |
| -_, axes = plt.subplots(nrows=3, figsize=(10, 6 * 3)) |
| 34 | +fig, axes = plt.subplots(nrows=3, figsize=(6, 8)) |
35 | 35 |
|
36 | 36 | # Make some data; a 1D random walk + small fraction of sine waves
|
37 | 37 | num_series = 1000
|
|
58 | 58 | axes[0].plot(x, Y.T, color="C0", alpha=0.1)
|
59 | 59 | toc = time.time()
|
60 | 60 | axes[0].set_title("Line plot with alpha")
|
61 |
| -print(f"{toc-tic:.2f} sec. elapsed") |
| 61 | +print(f"{toc-tic:.3f} sec. elapsed") |
62 | 62 |
|
63 | 63 |
|
64 | 64 | # Now we will convert the multiple time series into a histogram. Not only will
|
|
80 | 80 | cmap = copy(plt.cm.plasma)
|
81 | 81 | cmap.set_bad(cmap(0))
|
82 | 82 | h, xedges, yedges = np.histogram2d(x_fine, y_fine, bins=[400, 100])
|
83 |
| -axes[1].pcolormesh(xedges, yedges, h.T, cmap=cmap, norm=LogNorm(vmax=1.5e2)) |
| 83 | +axes[1].pcolormesh(xedges, yedges, h.T, cmap=cmap, |
| 84 | + norm=LogNorm(vmax=1.5e2), rasterized=True) |
84 | 85 | axes[1].set_title("2d histogram and log color scale")
|
85 | 86 |
|
86 | 87 | # Same data but on linear color scale
|
87 |
| -axes[2].pcolormesh(xedges, yedges, h.T, cmap=cmap, vmax=1.5e2) |
| 88 | +axes[2].pcolormesh(xedges, yedges, h.T, cmap=cmap, vmax=1.5e2, rasterized=True) |
88 | 89 | axes[2].set_title("2d histogram and linear color scale")
|
89 | 90 | toc = time.time()
|
90 |
| -print(f"{toc-tic:.2f} sec. elapsed") |
| 91 | +print(f"{toc-tic:.3f} sec. elapsed") |
91 | 92 |
|
| 93 | +fig.tight_layout() |
92 | 94 | plt.show()
|
0 commit comments