0

I am using PdfPages to save several images in one file, but saving a 2D colormesh in particular seems ridiculously slow.

Saving a 3D plot of my data takes about 10 seconds. These are made with

fig3 = mpl.figure()
fig, ax = mpl.subplots(subplot_kw={"projection": "3d"}, dpi = ndpi)
surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm, linewidth=0, antialiased=False)

I haven't been able to save the 2D colormap, even after waiting several minutes. This is the code to produce that map:

fig, ax = mpl.subplots(dpi = 200) #Saving this to pdf is VERY slow
ax.pcolormesh(X, Y, Z)

This is the code I use to save as PDF:

p = PdfPages(dataStr[0:-4]+'.pdf')
fig_nums = mpl.get_fignums()
figs = [mpl.figure(n) for n in fig_nums]

for fig in figs:
    fig.savefig(p, format='pdf')
    
p.close()

For reference, I added the 2D colormap as a picture.

Is PDF not the correct way of going about this? Is there an alternative?2D colormap

0 Answers0