在正常的matplotlib axes类中,可以将网格线设置为具有一定的透明度(alpha级别)。我尝试通过下面的APLpy包来利用这一点:
fig = pyplot.figure(figsize=(18,8))
gridspec_layout = gridspec.GridSpec(1,2)
gridspec_layout1 = gridspec.GridSpecFromSubplotSpec(3, 3, subplot_spec=gridspec_layout[1], hspace=0.0, wspace=0.0)
pyplot_0 = fig.add_subplot(gridspec_layout1[0])
pyplot_1 = fig.add_subplot(gridspec_layout1[1])
pyplot_2 = fig.add_subplot(gridspec_layout1[2])
pyplot_3 = fig.add_subplot(gridspec_layout1[3])
pyplot_4 = fig.add_subplot(gridspec_layout1[4])
pyplot_5 = fig.add_subplot(gridspec_layout1[5])
pyplot_6 = fig.add_subplot(gridspec_layout1[6])
pyplot_7 = fig.add_subplot(gridspec_layout1[7])
pyplot_8 = fig.add_subplot(gridspec_layout1[8])
M33 = aplpy.FITSFigure('myfits.fits', figure=fig, subplot=list(gridspec_layout[0].get_position(fig).bounds), dimensions=[0, 1], slices=[0])
M33 = aplpy.FITSFigure('myfits.fits')
M33.show_grid()
M33.set_grid_alpha(0.1)
pyplot.savefig('myeps.eps', format='eps', dpi=800, clobber=True)因此,透明度非常高,非常微妙。但是,当我将绘图另存为.eps格式文件时,透明度丢失,并且我的线条是白色的。在普通的matplotlib中,我通常使用:
ax.set_rasterized(True)这样透明度看起来就像它应该的那样。
我想知道是否有aplpy.FITSFigure类的等价物...?
非常感谢!
发布于 2016-06-14 21:36:57
在save函数中,有一个可选参数transparent。默认情况下,transparent设置为False。如果将其设置为True,则在保存时应保留透明度。
所以它应该是这样的:
M33.save(filename, transparent=True, ..)ETA:在下面的评论中,有人指出EPS格式不支持透明度,所以如果你用该格式保存,上面的代码将不起作用。
https://stackoverflow.com/questions/37813267
复制相似问题