【问题标题】:healpy: Formatting subplots治愈:格式化子图
【发布时间】:2019-01-09 15:56:29
【问题描述】:

我想使用 healpy 在一个图中绘制许多子图。如何:

  1. 设置颜色条的位置?
  2. 设置颜色条的刻度和刻度标签?
  3. 设置子图的位置和大小?

我想根据一般坐标在 MATLAB 中绘制如图 1 所示的图

现在,我只使用 healpy 将其绘制如下:

生成图3(类似于图2)的类似代码如下:

import numpy as np
import healpy as hp

degree = 4
nside = 2**degree
num_Pixel = hp.nside2npix(nside)

m = np.arange(num_Pixel)

margins = [[0.02,0,0,0],[0.01,0,0,0],[0.01,0,0.01,0],
        [0.02,0,0,0],[0.01,0,0,0],[0.01,0,0.01,0],
        [0.02,0.05,0,0],[0.01,0.05,0,0],[0.01,0.05,0.01,0]]

title = [
    'Equinox', 'Jun. Solstice', 'Dec. Solstice',
    '','','','','','']

for ifig in range(1,10):
    if ifig < 7:
       hp.cartview(
           m, sub=330+ifig, margins=margins[ifig1],
           cbar=False, title=title[ifig-1])
    else:
       hp.cartview(
           m, sub=330+ifig, margins=margins[ifig-1],
           cbar=True, title=title[ifig-1])

生成图3的代码

【问题讨论】:

    标签: python-3.x matplotlib healpy


    【解决方案1】:

    恐怕healpy 没有提供处理颜色条、刻度、刻度标签、轴等的好方法。

    最好的方法是根据您的 HEALPix 地图生成 FITS 图像(例如,使用 hp.cartview(..., return_projected_map=True) 或使用 reproject 包)。

    您还需要为此生成正确的 FITS 标头,astropy 将是正确的工具 (how-to manipulate FITS headers)。

    一旦你有了它,你就可以在astropy 中使用优秀的WCSAxes 框架,它为你提供了大量有据可查的自定义选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-26
      • 1970-01-01
      • 2018-11-11
      • 2022-10-09
      相关资源
      最近更新 更多