gpt4 book ai didi

python - matplotlib 在 .eps 文件中的 AxesSubplot 之外绘制等高线标签

转载 作者:太空宇宙 更新时间:2023-11-04 06:25:52 25 4
gpt4 key购买 nike

我正在使用导入为 PL 的 matplotlib.pyplot 制作绘图:

FIG = PL.figure(figsize=(12,8), dpi=150)
AX = FIG.add_subplot(111, aspect='equal', xlim=(lonMin,lonMax), ylim=(latMin,latMax))
PL.contourf(lon, lat, swath, range(2,56,1))
PL.colorbar(shrink=0.8, extend='both', ticks=range(5,55,5))
CNTR = PL.contour(lon, lat, rain, colors='black', linewidths=1)
PL.clabel(CNTR, fmt='%2i', inline_spacing=2)
PL.savefig('swaths_ao.png', bbox_inches='tight')
PL.savefig('swaths_ao.eps', bbox_inches='tight')
PL.savefig('swaths_ao.pdf', bbox_inches='tight')
PL.clf()

我遇到的问题是 PL.clabel 甚至在 AX 的限制之外绘制轮廓标签,也就是说,在图的空白处。这只发生在 .eps 文件中,但不会发生在 .png 或 .pdf 文件中。巧合的是,我需要 .eps。

关于如何解决这个问题的任何提示?

最佳答案

听起来像是一个错误,您可以将其归档为 an issue on Github ,但作为解决方法,如果 pdf 输出看起来正确,您可以使用 pdftops(xpdf 附带),然后使用 ps2eps .

关于python - matplotlib 在 .eps 文件中的 AxesSubplot 之外绘制等高线标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8189121/

25 4 0