python - 如何在 Mollweide 视图(Python)中绘制背景图像?
问题描述
我正在使用天空坐标进行天文数据分析。如何将图像放置为 Mollweide 视图图的背景?我尝试的是正常绘制图表并添加:
imag = mpimg.imread('gamma_ray_Fermi.png')
plt.imshow(imag)
但它只是返回一个变形图,而不是通常的背景图。
解决方案
感谢用户 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()
推荐阅读
- python - 在 Python 中拆分字符串而不破坏单词
- c# - 如何在编辑方法.net core mvc中使用automapper
- powershell - Powershell 将字符串转换为 mmddyyyy 格式的最干净方法
- mysql - 如何从 AWS Aurora 上的文件中导入某些数据
- javascript - 带单引号的单词中转义撇号(单引号)的正则表达式
- java - 与嵌套的 JPanel 混淆以及它们之间的间隙
- javascript - 如何使用 Laravel 在图表中显示当月的所有天数
- python - 将 BigQuery 中的可为空数据馈送到 TensorFlow 转换
- javascript - 将数据表单从 JavaScript 发送到 PHP,对其进行操作,然后使用 Fetch 将其发送回 JavaScript
- neural-network - R中的精密函数数值变量误差