當前位置: 首頁>>代碼示例>>Python>>正文


Python crs.Robinson方法代碼示例

本文整理匯總了Python中cartopy.crs.Robinson方法的典型用法代碼示例。如果您正苦於以下問題:Python crs.Robinson方法的具體用法?Python crs.Robinson怎麽用?Python crs.Robinson使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cartopy.crs的用法示例。


在下文中一共展示了crs.Robinson方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from cartopy import crs [as 別名]
# 或者: from cartopy.crs import Robinson [as 別名]
def main():
    ax = plt.axes(projection=ccrs.Robinson())

    # make the map global rather than have it zoom in to
    # the extents of any plotted data
    ax.set_global()

    ax.stock_img()
    ax.coastlines()

    # san diego
    sdlat, sdlon = 32.7157, -117.1611
    # brisbane
    brislat, brislon = -27.4698, 153.0251


    # NOTE: longitude before latitude!!
    plt.plot([sdlon, brislon], [sdlat, brislat], color='blue', linewidth=2,  transform=ccrs.Geodetic())



    plt.show() 
開發者ID:linsalrob,項目名稱:EdwardsLab,代碼行數:24,代碼來源:example.py

示例2: plot_extend

# 需要導入模塊: from cartopy import crs [as 別名]
# 或者: from cartopy.crs import Robinson [as 別名]
def plot_extend(resource, file_extension='png'):
    """
    plots the extend (domain) of the values stored in a netCDF file:

    :parm resource: path to netCDF file
    :param file_extension: file format of the graphic. if file_extension=None a matplotlib figure will be returned

    :return graphic: graphic in specified format
    """
    lats, lons = get_coordinates(resource, unrotate=True)

    # box_top = 45
    # x, y = [-20, -20, 45, 45, -44], [-45, box_top, box_top, -45, -45]

    xy = np.array([[np.min(lons), np.min(lats)],
                   [np.max(lons), np.min(lats)],
                   [np.max(lons), np.max(lats)],
                   [np.min(lons), np.max(lats)]])

    fig = plt.figure(figsize=(20, 10), dpi=600, facecolor='w', edgecolor='k')
    projection = ccrs.Robinson()

    #  ccrs.Orthographic(central_longitude=np.mean(xy[:, 0]),
    #  central_latitude=np.mean(xy[:, 1]),
    #  globe=None)  # Robinson()

    ax = plt.axes(projection=projection)
    ax.stock_img()
    ax.coastlines()
    ax.add_patch(mpatches.Polygon(xy, closed=True, transform=ccrs.PlateCarree(), color='coral', alpha=0.6))
    # ccrs.Geodetic()
    ax.gridlines()
    plt.show()

    if file_extension is None:
        map_graphic = fig
    else:
        map_graphic = fig2plot(fig=fig, file_extension=file_extension)
    plt.close()

    return map_graphic 
開發者ID:bird-house,項目名稱:flyingpigeon,代碼行數:43,代碼來源:plt_ncdata.py

示例3: plotmap

# 需要導入模塊: from cartopy import crs [as 別名]
# 或者: from cartopy.crs import Robinson [as 別名]
def plotmap(ll, dd, maxdist=1, maxlinewidth=3):
    """
    Plot the map of the dna distances and lat longs
    :param ll: The lon-lats
    :param dd: The distances to use
    :param maxdist: The maximum distance that we will scale to be maxlinewidth
    :return:
    """

    ax = plt.axes(projection=ccrs.Robinson())

    # make the map global rather than have it zoom in to
    # the extents of any plotted data
    ax.set_global()

    ax.stock_img()
    ax.coastlines()

    ## color the lines based on the maximum distance value
    jet = cm = plt.get_cmap('jet')
    cNorm = colors.Normalize(vmin=0, vmax=maxdist)
    scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=jet)

    # Using contourf to provide my colorbar info, then clearing the figure
    Z = [[0, 0], [0, 0]]
    levels = range(0, int(100 * maxdist) + 10, 10)
    CS3 = plt.contourf(Z, levels, cmap=jet)
#    plt.clf()




    # NOTE: longitude before latitude!!
    # plt.plot([sdlon, brislon], [sdlat, brislat], color='blue', linewidth=2,  transform=ccrs.Geodetic())
    samples = ll.keys()

    # plot the circles for each sample site
    for lonlat in ll.values():
        plt.plot(lonlat[0], lonlat[1], '*', markersize=18, transform=ccrs.PlateCarree())

    for idx1 in samples:
        for idx2 in samples:
            if idx1 == idx2:
                continue
            # this should only happen when we do best DNA distances
            if idx2 not in dd[idx1]:
                continue
            linewidth = dd[idx1][idx2]
            linewidth = linewidth/maxdist * maxlinewidth
            colorVal = scalarMap.to_rgba(dd[idx1][idx2])
            plt.plot([ll[idx1][0], ll[idx2][0]], [ll[idx1][1], ll[idx2][1]], color=colorVal, linewidth=linewidth, alpha=0.25, transform=ccrs.Geodetic())

#    plt.colorbar(CS3)

    plt.show() 
開發者ID:linsalrob,項目名稱:EdwardsLab,代碼行數:57,代碼來源:crAssphage_distance.py


注:本文中的cartopy.crs.Robinson方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。