gpt4 book ai didi

matplotlib - 将 3D 表面保存为 pdf 时出现黑线 : How can I get rid of them?

转载 作者:行者123 更新时间:2023-12-01 10:41:22 25 4
gpt4 key购买 nike

我有以下代码使用 ax.plot_surface 显示 3D 表面:

fig = plt.figure()
ax = fig.gca(projection='3d')
X,Y = np.meshgrid(range(k_mean.shape[0]), range(k_mean.shape[1]))
Z = k_mean
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, linewidth=0., alpha=0.8, cmap=cm.nipy_spectral, antialiased=False, shade=False)
cset = ax.contour(X, Y, Z, zdir='z', offset=0, cmap=cm.nipy_spectral)
cset = ax.contour(X, Y, Z, zdir='x', offset=0, cmap=cm.nipy_spectral)
cset = ax.contour(X, Y, Z, zdir='y', offset=120, cmap=cm.nipy_spectral)

ax.set_xlim(0, 120)
ax.set_ylim(0, 120)
ax.set_zlim(0, 1)

fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
plt.savefig('3d.pdf', dpi=500)

Spyder 中的绘图显示是“正确的”,但 PDF 似乎忽略了 linewidth=0.。我该如何解决?

Spyder 输出: Spyder output

PDF 输出: PDF output

最佳答案

matplotlib github 认为这是固定的,但修复没有进入 v1.4.1,但将放入 v1.4.3 https://github.com/matplotlib/matplotlib/issues/2247

关于matplotlib - 将 3D 表面保存为 pdf 时出现黑线 : How can I get rid of them?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29822498/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com