8000 resize plot, tight layout, rasterization, time sig figs · matplotlib/matplotlib@920588d · GitHub
[go: up one dir, main page]

Skip to content

Commit 920588d

Browse files
committed
resize plot, tight layout, rasterization, time sig figs
1 parent 818636e commit 920588d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

examples/statistics/time_series_histogram.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import matplotlib.pyplot as plt
3232
from matplotlib.colors import LogNorm
3333

34-
_, axes = plt.subplots(nrows=3, figsize=(10, 6 * 3))
34+
fig, axes = plt.subplots(nrows=3, figsize=(6, 8))
3535

3636
# Make some data; a 1D random walk + small fraction of sine waves
3737
num_series = 1000
@@ -58,7 +58,7 @@
5858
axes[0].plot(x, Y.T, color="C0", alpha=0.1)
5959
toc = time.time()
6060
axes[0].set_title("Line plot with alpha")
61-
print(f"{toc-tic:.2f} sec. elapsed")
61+
print(f"{toc-tic:.3f} sec. elapsed")
6262

6363

6464
# Now we will convert the multiple time series into a histogram. Not only will
@@ -80,13 +80,15 @@
8080
cmap = copy(plt.cm.plasma)
8181
cmap.set_bad(cmap(0))
8282
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)
8485
axes[1].set_title("2d histogram and log color scale")
8586

8687
# 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)
8889
axes[2].set_title("2d histogram and linear color scale")
8990
toc = time.time()
90-
print(f"{toc-tic:.2f} sec. elapsed")
91+
print(f"{toc-tic:.3f} sec. elapsed")
9192

93+
fig.tight_layout()
9294
plt.show()

0 commit comments

Comments
 (0)
0