下面是我在评论中建议的答案:
大的pdf/svg文件是将pcolormesh中的每个矩形存储为矢量图形的结果。在
我希望将绘图存储为svg/pdf的目的是获得一个高分辨率的图像,在该图像中,一旦我将文件插入到我的latex文档中,文本就会呈现出来。如果分辨率足够好,绘图本身并不需要是矢量图形。在
所以我的建议是(导入的库和上面一样):mpl.use('svg')
new_rc_params = {
"font.family": 'Times', #probably python doesn't know Times, but it will replace it with a different font anyway. The final decision is up to the latex document anyway
"font.size": 12, #choosing the font size helps latex to place all the labels, ticks etc. in the right place
"font.serif": [],
"svg.fonttype": 'none'} #to store text as text, not as path
mpl.rcParams.update(new_rc_params)
plt.figure(figsize = (6.49/2, 6.49/2)) #that's about half the text width of an A4 document
plt.pcolormesh(x, y, z, rasterized = True) # That's the