简体   繁体   English

APLpy / matplotlib:协调EPS质量图的网格Alpha级别

[英]APLpy/matplotlib: Coordinate grid alpha levels for EPS quality figure

In the normal matplotlib axes class, it is possible to set gridlines to have a certain transparency (alpha level). 在普通的matplotlib轴类中,可以将网格线设置为具有一定的透明度(alpha级别)。 I'm attempting to utilise this with the APLpy package using the following: 我正在尝试通过以下方法将其与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)

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. 但是,当我将图另存为.eps格式文件时,透明度会丢失,并且线条为白色。 In normal matplotlib, I usually use: 在普通的matplotlib中,我通常使用:

ax.set_rasterized(True)

Such that the transparency kind of looks as it should. 这样透明度就应该看起来像。

I was wondering if there were an equivalent for the aplpy.FITSFigure class...? 我想知道aplpy.FITSFigure类是否等效...?

Many thanks! 非常感谢!

In the save function, there is an optional argument, transparent. 在save函数中,有一个可选参数透明。 transparent is set to False by default. 透明默认情况下设置为False。 If you set it to True, the transparency should be preserved when you save. 如果将其设置为True,则保存时应保留透明度。

So it should be something like: 所以应该是这样的:

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

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. 预计到达时间:在下面的评论中,指出EPS格式不支持透明性,因此如果以该格式保存,则上面的代码将不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM