The comments have a good solution that utilizes imshow
. When imshow
is not appropriate for the input data (e.g. it is not uniformly spaced) this generally solves this problem,
pcol = pl.pcolormesh(x,y,z,cmap="Blues",linewidth=0,)
pcol.set_edgecolor('face')
If that approach does not reduce the lines sufficiently, you can also try this:
pl.pcolormesh(x,y,z,cmap="Blues",linewidth=0,rasterized=True)
In addition to reducing the lines between squares this approach also tends to reduce file size a bit, which is sometimes useful. In this case you may want to tune the dpi
setting when saving (e.g. pl.savefig("heatmap.pdf", dpi=300)
) until you get something that is satisfactory.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…