当前位置: 首页>>代码示例>>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;未经允许,请勿转载。