APLpy/matplotlib:协调EPS质量图的网格Alpha级别 [英] APLpy/matplotlib: Coordinate grid alpha levels for EPS quality figure

查看:210
本文介绍了APLpy/matplotlib:协调EPS质量图的网格Alpha级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在普通的matplotlib轴类中,可以将网格线设置为具有一定的透明度(alpha级别).我正在尝试通过以下方法将其与APLpy软件包一起使用:

In the normal matplotlib axes class, it is possible to set gridlines to have a certain transparency (alpha level). I'm attempting to utilise this with the APLpy package using the following:

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中,我通常使用:

So the transparency is very high and very subtle. However, when I save the plot as an .eps format file, the transparency is lost and my lines are white. In normal matplotlib, I usually use:

ax.set_rasterized(True)

这种透明度看起来应该是应该的.

Such that the transparency kind of looks as it should.

我想知道aplpy.FITSFigure类是否等效...?

I was wondering if there were an equivalent for the aplpy.FITSFigure class...?

非常感谢!

推荐答案

在save函数中,有一个可选的参数透明.透明默认情况下设置为False.如果将其设置为True,则保存时应保留透明度.

In the save function, there is an optional argument, transparent. transparent is set to False by default. If you set it to True, the transparency should be preserved when you save.

所以应该是这样的:

M33.save(filename, transparent=True, ..)

ETA:在下面的评论中,有人指出EPS格式不支持透明性,因此,如果以这种格式保存,则上面的代码将不起作用.

ETA: In the comments below it was pointed out that the EPS format does not support transparency, so the above code will not work if you're saving in that format.

这篇关于APLpy/matplotlib:协调EPS质量图的网格Alpha级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆