我在用matplotlib.pyplot.subplot为了创建一个3x3打印b/c,它很容易共享轴。然后在每个子图中绘制一个轮廓图和等高线图。在等高线图中放置文本时,内联间距仅在最后一次绘图中正确,否则没有内联间距。就好像我没有打开前8个子窗口的内联文本。我的代码是:
import numpy as np
import matplotlib.pyplot as plt
import rfFile, rfMath, rfGeneral
plt.ion()
de_1 = list(np.linspace(0,100,101))
de_2 = list(np.linspace(0,100,101))
gain_2 = np.linspace(0,16,9)
levels = np.linspace(0,100,11)
de = np.array([[x,y] for x in de_1 for y in de_2])
dx = de[:,0]
dy = de[:,1]
xytri = rfGeneral.createTriMesh(dx, dy, 2)
fig, ax = plt.subplots(nrows=3, ncols=3, sharex=True, sharey=True)
ax = ax.flatten()
for ix, g in enumerate(gain_2):
print g
de_tot = [(x*y)/(x + y/rfMath.db2lin(g)) for x in de_1 for y in de_2]
de_tot = np.nan_to_num(de_tot)
cs = ax[ix].tricontourf(xytri, de_tot, levels)
ax[ix].set_title('Gain: {:2.0f} dB'.format(g))
cs1 = ax[ix].tricontour(xytri, de_tot, levels, linewidths=1.5, colors='k')
ax[ix].clabel(cs1, fmt = '%2.0f', fontsize=14, inline=1)
ax[0].set_ylim(min(de_2),max(de_2))
ax[0].set_xlim(min(de_1),max(de_1))
cax = plt.axes([0.93, 0.1, 0.025, 0.8])
fig.colorbar(cs, cax=cax)
ax[7].set_xlabel(r'$\eta_{D1}\,[\%]$',fontdict={'fontsize':20})
ax[3].set_ylabel(r'$\eta_{D2}\,[\%]$',fontdict={'fontsize':20})
fig.suptitle('Total Drain Efficiency', fontsize=24)
plt.subplots_adjust(top=0.9, left=0.075, right=0.9)
如果你发布一个简单的例子,让人们可以立即复制这个问题,这会有帮助。rf*模块(它们是什么?)使其他人无法运行您的代码,只会混淆问题的原因。在
也就是说,将
sharex
和sharey
设置为False
可能会解决您的问题。您可以根据数据手动设置x和y限制。在我不知道是什么原因造成了这个问题。也许共享轴会对剪辑路径应用某种变换,这只对最后一个轴有效。在我看来它像个虫子。在
共享轴:
无共享轴:
^{pr2}$相关问题 更多 >
编程相关推荐