python中fill的逆运算

2024-05-06 01:23:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用Matplotlib的“Mollweide”投影来绘制下面的情节。我使用ax.fill对由eff数组中的点定义的区域进行着色。然而,我需要的是这个的转置。我需要阴影的所有地区的绘图除了一个封闭的二维数组。我该怎么做?你知道吗

这是一个最小的代码。你知道吗

import ephem
import numpy as np
import matplotlib.pyplot as plt
ra_array = np.arange(0,360)

def invert(inp):
    x = np.remainder(inp+360-org,360) # shift RA values
    ind = x>180
    x[ind] -=360    # scale conversion to [-180, 180]
    return x

def get_gal_array(dec):
    ga_array = np.zeros((360,2))
    for ra in ra_array:
        eq = ephem.Equatorial(np.radians(ra), np.radians(dec))
        ga = ephem.Galactic(eq) 
        ga_array[ra] = np.degrees(ga.get())
    return np.radians(invert(ga_array[:,0])),np.radians(ga_array[:,1])

org = 0
fig = plt.figure(figsize=(10, 5))
ax = fig.add_subplot(111, projection="mollweide")
ax.set_xticklabels(tick_labels)     
ax.set_title("TesT")
ax.title.set_fontsize(15)
ax.set_xlabel("GL")
ax.xaxis.label.set_fontsize(12)
ax.set_ylabel("GB")
ax.yaxis.label.set_fontsize(12)
ax.grid(True)
eff = get_gal_array(-28)#eff is a 2D array of points
ax.scatter(eff[0],eff[1], s=3,  label="Effelsberg")
ax.fill(eff[0],eff[1])

example image


Tags: importgetnp数组axarrayfilllabel