Matplotlib 如何在每个象限绘制半径不同的圆?

Matplotlib 如何在每个象限绘制半径不同的圆?,matplotlib,geometry,matplotlib-basemap,cartopy,metpy,Matplotlib,Geometry,Matplotlib Basemap,Cartopy,Metpy,我想画一个类似以下示例的形状(来自海军研究实验室TC页面)。形状由4个半径定义,每个象限一个半径 我在纬度和经度坐标中有多个轨迹中心,我使用底图绘制这些中心: def m_plot_wind_speeds(x,y, mps): # There's a switch-like statement here to determine the color of the # line based on wind speed which I ignored. This is passe

我想画一个类似以下示例的形状(来自海军研究实验室TC页面)。形状由4个半径定义,每个象限一个半径

我在纬度和经度坐标中有多个轨迹中心,我使用底图绘制这些中心:

def m_plot_wind_speeds(x,y, mps):

    # There's a switch-like statement here to determine the color of the
    # line based on wind speed which I ignored. This is passed to the 
    # color kwarg in m.plot as cur_color. 

    m.plot(x,y, '.-', markersize=ms, linewidth=lw, color=cur_color, \
 mew=1.5, markerfacecolor='k')

m = Basemap(projection='cyl',area_thresh=1000, \
    llcrnrlat=southLat,urcrnrlat=northLat,llcrnrlon=westLong,urcrnrlon=eastLong,resolution='h')
parallels = np.arange(southLat,northLat+10,10.) # make latitude lines ever 5 degrees from 30N-50N
meridians = np.arange(westLong,eastLong+30,30.) # make longitude lines every 5 degrees from 95W to 70W

m.drawparallels(parallels,labels=[1,0,0,0],labelstyle="+/-", linewidth=0, fontsize=6)
m.drawmeridians(meridians,labels=[0,0,0,1],labelstyle="+/-", linewidth=0, fontsize=6)
m.drawcountries(linewidth=0.25)

m.bluemarble()

# data is a [10]x[~]x[10] list. There are 10 trajectories, each with
# varying lengths. Each trajectory has 10 attributes.

for traj in data:
    lat = []
    lon = []
    wind_speed=[]

    for i in traj:
        lat.append(float(i[1]))
        lon.append(float(i[0]))
        wind_speed.append(float(i[2]))

   for j,var in enumerate(traj):
        if j > 0:
            x,y = m([lon[j], lon[j-1]], [lat[j], lat[j-1]])
        else:
            x,y = m([lon[j], lon[j]],[lat[j], lat[j]])
        m_plot_wind_speeds(x,y,wind_speed[j])


        # TODO: Insert a function here that takes in a 4 radii and plots them 
        # in each quadrant.

如果你不介意直线朝向中心,可以使用

或者,可以使用和绘制轮廓。您仍然需要楔子或精心制作的多边形来填充

将numpy导入为np
从matplotlib导入修补程序
将matplotlib.pyplot作为plt导入
def绘制象限弧(X中心,Y中心,半径,lw=2,ec='crimson',ax=None):
ax=ax或plt.gca()
对于rad,zip中的θ(半径[0,90,180,270]):
弧=面片。弧((X中心,Y中心),2*rad,2*rad,θ1=θ,θ2=θ+90,
lw=lw,ec=ec,fc='无')
ax.添加补片(圆弧)
ax.hline([cCenter,cCenter],[xcenter+半径[0],xcenter-半径[1],[xcenter+半径[3],xcenter-半径[2],
lw=lw,颜色=ec)
轴线([xcenter,xcenter],[cCenter+半径[0],cCenter-半径[2],[cCenter+半径[1],cCenter-半径[3],
lw=lw,颜色=ec)
def绘制象限(X中心、Y中心、半径、lw=2、ec='crimson',fc='lime',alpha=1、ax=None):
ax=ax或plt.gca()
对于rad,zip中的θ(半径[0,90,180,270]):
楔形=面片。楔形((X中心,Y中心),弧度,θ,θ+90,
lw=lw,ec=ec,fc=fc,alpha=alpha)
ax.添加补片(楔块)
xcenter,cCenter=6,10
半径=[6,2,4,7]
#只有楔子
绘制象限和楔块(X中心、Y中心、半径)
#只有圆弧
绘制象限和圆弧(X中心+12,Y中心,半径)
#楔子和弧在一起
绘制四象限楔形(X中心+24,Y中心,半径,ec='无',lw=0,fc='limegreen',alpha=0.3)
绘制象限和圆弧(X中心+24,Y中心,半径)
plt.xlim(0,40)
plt.ylim(0,20)
plt.gca().set_aspect('equal','box'))
plt.show()

如果回答了你的问题,你可以考虑点击复选标记来把答案标记为“接受”。