包含的代码大约需要2分钟才能运行,并创建一个22 MB的pdf。有没有办法将每个保存的数字的大小限制在合理的限度(即1 mb)?
我已经检查了fig.get_dpi(),它报告了80,对于一个4“x 6”的数字应该是合理的大小。
%matplotlib inline
import numpy as np
from numpy.random import randn
from matplotlib.backends.backend_pdf import PdfPages
# This will be the basic way for me to save figures
pp = PdfPages('test.pdf')
# Simulate and plot random data
dr = 1
rMax = 300
rRange = np.arange(0, rMax, dr)
R, Z = np.meshgrid(rRange, rRange)
Y = randn(R.shape[0], R.shape[1])
fig, ax = subplots()
ax.pcolor(R, Z, Y, cmap='RdBu')
# Save figure and produce pdf
pp.savefig(fig)
pp.close()