用透明背景保存Matplotlib suface-plot

问题描述

我尝试使用透明背景保存3d图,但是使用savefig的transparent = True-Parameter时,它不起作用。还有其他方法吗?

这是我的实际尝试:

import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator,FormatStrFormatter
import numpy as np
from scipy import interpolate


Z = abs(p_r) #p_r = 2-dimensional complex valued numpy-Array (4x4) 

X,Y = np.meshgrid(np.arange(-0.06,0.07,0.04),np.arange(-0.06,0.04))
xnew,ynew = np.mgrid[-0.06:0.06:10j,-0.06:0.06:10j]
tck = interpolate.bisplrep(X,Y,Z,s=0)
znew = interpolate.bisplev(xnew[:,0],ynew[0,:],tck)

fig = plt.figure()
ax = fig.gca(projection='3d')
    
surf = ax.plot_surface(xnew,ynew,znew,cmap=cmap,linewidth=0,antialiased=False,shade=False)

ax.set_zlim(0,0.9)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))

ax.set_xlabel('x [m]')
ax.set_ylabel('y [m]')
ax.set_zlabel('Amplitude [Pa]')

plt.savefig(graPHPath,tranparent=True)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)