【发布时间】:2018-07-23 14:36:16
【问题描述】:
我正在使用天空坐标进行天文数据分析。如何将图像放置为 Mollweide 视图图的背景?我尝试的是正常绘制图表并添加:
imag = mpimg.imread('gamma_ray_Fermi.png')
plt.imshow(imag)
但它只是返回一个变形的图形,而不是通常的背景图。
【问题讨论】:
标签: python matplotlib plot astronomy
我正在使用天空坐标进行天文数据分析。如何将图像放置为 Mollweide 视图图的背景?我尝试的是正常绘制图表并添加:
imag = mpimg.imread('gamma_ray_Fermi.png')
plt.imshow(imag)
但它只是返回一个变形的图形,而不是通常的背景图。
【问题讨论】:
标签: python matplotlib plot astronomy
感谢用户 ImportanceOfBeingErnest 的评论,了解它的工作原理。这是有效的代码:
import numpy as np
import matplotlib.pyplot as plt
data = plt.imread("yourimagehere.png")
fig = plt.figure()
#create axes in the background to show cartesian image
ax0 = fig.add_subplot(111)
ax0.imshow(data)
ax0.axis("off")
# create polar axes in the foreground and remove its background
# to see through
ax = fig.add_subplot(111, projection="mollweide", label="polar")
#you can change to other projections like "hammer"
ax.set_facecolor("None")
plt.show()
【讨论】: