【问题标题】:How to plot a background image in Mollweide view (Python)?如何在 Mollweide 视图(Python)中绘制背景图像?
【发布时间】:2018-07-23 14:36:16
【问题描述】:

我正在使用天空坐标进行天文数据分析。如何将图像放置为 Mollweide 视图图的背景?我尝试的是正常绘制图表并添加:

imag = mpimg.imread('gamma_ray_Fermi.png')
plt.imshow(imag)

但它只是返回一个变形的图形,而不是通常的背景图。

【问题讨论】:

标签: python matplotlib plot astronomy


【解决方案1】:

感谢用户 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()

【讨论】:

    猜你喜欢
    • 2016-03-31
    • 2013-04-10
    • 2012-02-23
    • 1970-01-01
    • 1970-01-01
    • 2012-12-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多