当前位置: 首页>>代码示例>>Python>>正文


Python Polygon.set_edgecolor方法代码示例

本文整理汇总了Python中matplotlib.patches.Polygon.set_edgecolor方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.set_edgecolor方法的具体用法?Python Polygon.set_edgecolor怎么用?Python Polygon.set_edgecolor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.patches.Polygon的用法示例。


在下文中一共展示了Polygon.set_edgecolor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plot_fits_map

# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_edgecolor [as 别名]

#.........这里部分代码省略.........

    # Set the format of the major tick mark and labels
    if w['coord_type']=='EQU':
        f = 15.0
        majorFormatterX = FuncFormatter(label_format_hms)
        minorFormatterX = None
        majorFormatterY = FuncFormatter(label_format_dms)
        minorFormattery = None
    else:
        f = 1.0
        majorFormatterX = FuncFormatter(label_format_deg)
        minorFormatterX = None
        majorFormatterY = FuncFormatter(label_format_deg)
        minorFormattery = None
    ax.xaxis.set_major_formatter(majorFormatterX)
    ax.yaxis.set_major_formatter(majorFormatterY)
    
    # Set the location of the the major tick marks
    #xrangeArcmin = abs(w['xmax']-w['xmin'])*(60.0*f)
    #xmultiple = m.ceil(xrangeArcmin/3.0)/(60.0*f)
    #yrangeArcmin = abs(w['ymax']-w['ymin'])*60.0
    #ymultiple = m.ceil(yrangeArcmin/3.0)/60.0
    #majorLocatorX = MultipleLocator(xmultiple)
    #ax.xaxis.set_major_locator(majorLocatorX)
    #majorLocatorY = MultipleLocator(ymultiple)
    #ax.yaxis.set_major_locator(majorLocatorY)
    
    ax.xaxis.set_major_locator(MaxNLocator(5))
    ax.yaxis.set_major_locator(MaxNLocator(5))
    
    # Print the image to the axis
    im = ax.imshow(data, interpolation=interpolation, origin='lower',
                   aspect=aspect, 
                   extent=[w['xmax'], w['xmin'], w['ymin'], w['ymax']],
                   cmap=plt.get_cmap(cmapName), norm=normalizer) 
    
    # Add the colorbar
    if doColbar:
        cbar = fig.colorbar(im, pad=0.0)
        if 'BUNIT' in header:
            cbar.set_label(header['BUNIT'])
        else:
            cbar.set_label('Unknown')
        if not bunit is None:
            cbar.set_label(bunit)
        
    # Format the colourbar labels - TODO

    # Set white ticks
    ax.tick_params(pad=5)
    for line in ax.xaxis.get_ticklines() + ax.get_yticklines():
        line.set_markeredgewidth(1)
        line.set_color('w')

    # Create the ellipse source annotations
    if len(annEllipseLst) > 0:
        if len(annEllipseLst) >= 5:
            srcXLst = np.array(annEllipseLst[0])
            srcYLst = np.array(annEllipseLst[1])
            srcMinLst = np.array(annEllipseLst[2])
            srcMajLst = np.array(annEllipseLst[3])
            srcPALst = np.array(annEllipseLst[4])
        if len(annEllipseLst) >= 6:
            if type(annEllipseLst[5]) is str:
                srcEColLst = [annEllipseLst[5]] * len(srcXLst)
            elif type(annEllipseLst[5]) is list:
                srcEColLst = annEllipseLst[5]
            else:
                rcEColLst = ['g'] * len(srcXLst)
        else:
            srcEColLst = ['g'] * len(srcXLst)
        for i in range(len(srcXLst)):
            try:
                el = Ellipse((srcXLst[i], srcYLst[i]), srcMinLst[i],
                             srcMajLst[i], angle=180.0-srcPALst[i],
                             edgecolor=srcEColLst[i],
                             linewidth=lw, facecolor='none')
                ax.add_artist(el)
            except Exception:
                pass
        
    # Create the polygon source annotations
    if len(annPolyLst) > 0:
        annPolyCoordLst = annPolyLst[0]
        if len(annPolyLst) > 1:
            if type(annPolyLst[1]) is str:
                annPolyColorLst = [annPolyLst[1]] * len(annPolyCoordLst)
            elif type(annPolyLst[1]) is list:
                annPolyColorLst = annPolyLst[1]
            else:
                annPolyColorLst = ['g'] * len(annPolyCoordLst)
        else:
            annPolyColorLst = ['g'] * len(annPolyCoordLst)
        for i in range(len(annPolyCoordLst)):
            cpoly = Polygon(annPolyCoordLst[i], animated=False, linewidth=lw)
            cpoly.set_edgecolor(annPolyColorLst[i])
            cpoly.set_facecolor('none')
            ax.add_patch(cpoly)
    
    return fig
开发者ID:crpurcell,项目名称:RMpipeL5,代码行数:104,代码来源:util_plotFITS.py

示例2: float

# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_edgecolor [as 别名]
# csvfile = csv.reader(infile)




# for line in csvfile:
#     lon = (float(line[0]) + float(line[2]))/2 + float(line[5])
#     lat = (float(line[1]) + float(line[3]))/2 + float(line[6])
#     x, y = m(lon, lat)
#     name = line[4].replace('\\n', '\n')
#     plt.text(x, y, name, horizontalalignment='center', verticalalignment='center', fontsize=int(line[7]))

for lakepoly in m.lakepolygons:
    lp = Polygon(lakepoly.boundary, zorder=2)
    lp.set_facecolor('0.8')
    lp.set_edgecolor('0.8')
    lp.set_linewidth(0.1)
    ax.add_patch(lp)


# xx, yy = m(-72.0, 26.0)
# plt.text(xx, yy, u'Made by zhyuey', color='yellow')

# plt.title('Map of contiguous United States', fontsize=24)

# # plt.savefig('usa_state_75.png', dpi=75)
# # plt.savefig('usa_state_75.png', dpi=75)
# plt.savefig('usa_state_300.png', dpi=300)
# # plt.savefig('usa_state_600.png', dpi=600)

# m.drawcoastlines(linewidth=0.3)
开发者ID:yuejiahua,项目名称:maps,代码行数:33,代码来源:cn_map_cities.py

示例3: plotfits1

# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_edgecolor [as 别名]

#.........这里部分代码省略.........
    fig = plt.figure(figsize=(9.5,8))
    ax = fig.add_subplot(111, position=[0.1,0.08,0.9,0.87])      # Single pane
    if w['coord_type']=='EQU':
        ax.set_xlabel('RA (J2000)')
        ax.set_ylabel('Dec (J2000)')
    elif w['coord_type']=='GAL':
        ax.set_xlabel('Galactic Longitude (Deg)') 
        ax.set_ylabel('Galactic Latitude (Deg)')
    else:
        ax.set_xlabel('Unknown') 
        ax.set_ylabel('Unknown')    
    cosy = m.cos(m.radians(w['ycent']))
    aspect = abs(w['ydelt']/(w['xdelt']*cosy))

    # Set the format of the tick mark labels
    if w['coord_type']=='EQU':
        f = 15.0
        majorFormatterX = FuncFormatter(label_format_hms)
        minorFormatterX = None
        majorFormatterY = FuncFormatter(label_format_dms)
        minorFormattery = None
    else:
        f = 1.0
        majorFormatterX = FuncFormatter(label_format_deg)
        minorFormatterX = None
        majorFormatterY = FuncFormatter(label_format_deg)
        minorFormattery = None
    ax.xaxis.set_major_formatter(majorFormatterX)
    ax.yaxis.set_major_formatter(majorFormatterY)
        
    xrangeArcmin = abs(w['xmax']-w['xmin'])*(60.0*f)
    xmultiple = m.ceil(xrangeArcmin/4.0)/(60.0*f)

    yrangeArcmin = abs(w['ymax']-w['ymin'])*60.0
    ymultiple = m.ceil(yrangeArcmin/4.0)/60.0

    
    majorLocatorX = MultipleLocator(xmultiple)
    ax.xaxis.set_major_locator(majorLocatorX)

    majorLocatorY = MultipleLocator(ymultiple)
    ax.yaxis.set_major_locator(majorLocatorY)

    # Print the image to the figure
    im = ax.imshow(data,interpolation=interpolation,origin='lower',
                   aspect=aspect,
                   extent=[w['xmax'],w['xmin'],w['ymin'],w['ymax']],
                   cmap=plt.get_cmap(cmapName),norm=normalizer) 
    
    # Add the colorbar
    cbar = fig.colorbar(im ,pad=0.0)
    cbar.set_label('mJy/beam')

    # Set white ticks
    for line in ax.xaxis.get_ticklines():
        line.set_color('w')
    for line in ax.yaxis.get_ticklines():
        line.set_color('w')

    # Create the ellipse source annotations
    if len(annEllipseLst) > 0:
        if len(annEllipseLst) >= 5:
            srcRALst = np.array(annEllipseLst[0])
            srcDecLst = np.array(annEllipseLst[1])
            srcMinLst = np.array(annEllipseLst[2])
            srcMajLst = np.array(annEllipseLst[3])
            srcPALst = np.array(annEllipseLst[4])
        if len(annEllipseLst) >= 6:
            if type(annEllipseLst[5]) is str:
                srcEColLst = [annEllipseLst[5]] * len(srcRALst)
            elif type(annEllipseLst[5]) is list:
                srcEColLst = annEllipseLst[5]
            else:
                rcEColLst = ['g'] * len(srcRALst)
        else:
            srcEColLst = ['g'] * len(srcRALst)
        for i in range(len(srcRALst)):
            el = Ellipse((srcRALst[i],srcDecLst[i]), srcMinLst[i],
                         srcMajLst[i], angle=180-srcPALst[i],
                         edgecolor=srcEColLst[i],
                         linewidth=lw, facecolor='none')
            ax.add_artist(el)
        
    # Create the polygon source annotations
    if len(annPolyLst) > 0:
        if type(annPolyColor) is str:
            annPolyColor = [annPolyColor] * len(annPolyLst)
        elif type(annPolyColor) is list:
            pass
        else:
            annPolyColor =['g'] * len(annPolyLst)
        for i in range(len(annPolyLst)):
            cpoly = Polygon(annPolyLst[i], animated=False,linewidth=lw)
            cpoly.set_edgecolor(annPolyColor[i])
            cpoly.set_facecolor('none')
            ax.add_patch(cpoly)

    # Save to an image file (full-size & thumbnail images)
    fig.savefig(outFile, dpi=dpi)
    plt.close()
开发者ID:crpurcell,项目名称:pyutils,代码行数:104,代码来源:util_plotfits.py

示例4: plot_planform

# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_edgecolor [as 别名]
def plot_planform(c_r, c_k, c_t, b_k, b, Lambda_le_1, Lambda_le_2, *args, **kwargs):

    fig = plt.subplots(figsize=(9, 9))
    
    # optional arguments
    c_mac = kwargs.get('mac', None)
    X_le_mac = kwargs.get('X_le_mac', None)
    Y_mac = kwargs.get('Y_mac', None)
    X_ac = kwargs.get('X_ac', None)
    
    xLineWing = [0, b_k/2, b/2, b/2, b_k/2, 0]
    dy_k = (b_k/2)*math.tan(Lambda_le_1)
    dy = dy_k + (b/2 - b_k/2)*math.tan(Lambda_le_2)
    yLineWing = [
        0, 
        dy_k, 
        dy,
        dy + c_t, 
        dy_k + c_k, 
        c_r]
        
    # planform
    lineWing, = plt.plot(xLineWing, yLineWing, 'k-')

    plt.scatter(xLineWing, yLineWing, marker='o', s=40)    
    
    # centerline
    centerLine, = plt.plot([0,0], [-0.2*c_r,2.1*c_r], 'b')
    centerLine.set_dashes([8, 4, 2, 4]) 
    # c/4 line
    pC4r = [0, 0.25*c_r]
    pC4k = [b_k/2, dy_k + 0.25*c_k]
    pC4t = [b/2, dy + 0.25*c_t]
    quarterChordLine, = plt.plot([pC4r[0],pC4k[0],pC4t[0]], [pC4r[1],pC4k[1],pC4t[1]], 'k--')
    plt.scatter([pC4r[0],pC4k[0],pC4t[0]], [pC4r[1],pC4k[1],pC4t[1]], marker='o', s=40)

    if ('mac' in kwargs) and ('X_le_mac' in kwargs) and ('Y_mac' in kwargs):
        c_mac = kwargs['mac']
        X_le_mac = kwargs['X_le_mac']
        Y_mac = kwargs['Y_mac']
        #print(mac)
        #print(X_le_mac)
        #print(Y_mac)
        lineMAC, = plt.plot([Y_mac, Y_mac], [X_le_mac, X_le_mac + c_mac], color="red", linewidth=2.5, linestyle="-")
        lineMAC.set_dashes([1000,1]) # HUUUUGE
        lineLEMAC, = plt.plot([0,b/2], [X_le_mac,X_le_mac], color="orange", linewidth=1.5, linestyle="-")
        lineLEMAC.set_dashes([10,2])
        lineTEMAC, = plt.plot([0,b/2], [X_le_mac + c_mac, X_le_mac + c_mac], color="orange", linewidth=1.5, linestyle="-")
        lineTEMAC.set_dashes([10,2])
        plt.scatter(Y_mac, X_le_mac, marker='o', s=40)
        ax = plt.gca()  # gca stands for 'get current axis'
        ax.annotate(
            r'$(Y_{\bar{c}},X_{\mathrm{le},\bar{c}}) = '
                +r'( {0:.3}'.format(Y_mac) + r'\,\mathrm{m}'+r',\,{0:.3}'.format(X_le_mac) + r'\,\mathrm{m} )$',
                         xy=(Y_mac, X_le_mac), xycoords='data',
                         xytext=(20, 30), textcoords='offset points', fontsize=12,
                         arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2")) # 

    if ('X_le_r_eq' in kwargs) and ('c_r_eq' in kwargs):
        X_le_r_eq = kwargs['X_le_r_eq']
        c_r_eq = kwargs['c_r_eq']
        vertices = [(0, X_le_r_eq)] + [(b/2, dy)] + [(b/2, dy+c_t)] + [(0, X_le_r_eq + c_r_eq)]
        poly = Polygon(vertices, facecolor="yellow", alpha=0.5)
        poly.set_edgecolor("brown")
        poly.set_linewidth(2)
        ax0 = plt.gca()  # gca stands for 'get current axis'
        ax0.add_patch(poly)
        
    if 'X_ac' in kwargs:
        X_ac = kwargs['X_ac']
        #print(X_ac)
        plt.scatter(0, X_ac, marker='o', s=40)
        lineAC, = plt.plot([0,b/2], [X_ac,X_ac], color="brown", linewidth=3.5, linestyle="-")
        lineAC.set_dashes([10,2.5,3,2.5])
        ax = plt.gca()  # gca stands for 'get current axis'
        ax.annotate(r'$X_{\mathrm{ac,W}} = '+r'{0:.3}'.format(X_ac)+r'\,\mathrm{m} $',
                         xy=(b/2, X_ac), xycoords='data',
                         xytext=(20, 30), textcoords='offset points', fontsize=12,
                         arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2")) # 

    plt.axis('equal')
    
    #    xmajorLocator = MultipleLocator(2.0)
    #    xmajorFormatter = FormatStrFormatter('%.1f')
    #    xminorLocator = MultipleLocator(4)
    #    ax = plt.gca()  # gca stands for 'get current axis'
    #    ax.xaxis.set_major_locator(xmajorLocator)
    #    ax.xaxis.set_major_formatter(xmajorFormatter)
    #    # for the minor ticks, use no labels; default NullFormatter
    #    ax.xaxis.set_minor_locator(xminorLocator)
    
    plt.axis([-0.02*b/2, 1.1*b/2, -0.05*c_r, 1.1*(dy + c_t)])
    plt.gca().invert_yaxis()
    plt.title('Wing planform', fontsize=16)
    plt.xlabel('$y$ (m)', fontsize=16)
    plt.ylabel('$X$ (m)', fontsize=16)
    # Moving spines
    ax = plt.gca()  # gca stands for 'get current axis'
    ax.spines['right'].set_color('none')
    ax.spines['top'].set_color('none')
#.........这里部分代码省略.........
开发者ID:Aircraft-Design-UniNa,项目名称:aircraft-design-docs,代码行数:103,代码来源:init.py


注:本文中的matplotlib.patches.Polygon.set_edgecolor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。