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


Python ticker.LongitudeFormatter方法代码示例

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


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

示例1: _setup_map

# 需要导入模块: from cartopy.mpl import ticker [as 别名]
# 或者: from cartopy.mpl.ticker import LongitudeFormatter [as 别名]
def _setup_map(
    ax, xticks, yticks, crs, region, land=None, ocean=None, borders=None, states=None
):
    """
    Setup a Cartopy map with land and ocean features and proper tick labels.
    """

    if land is not None:
        ax.add_feature(cfeature.LAND, facecolor=land)
    if ocean is not None:
        ax.add_feature(cfeature.OCEAN, facecolor=ocean)
    if borders is not None:
        ax.add_feature(cfeature.BORDERS, linewidth=borders)
    if states is not None:
        ax.add_feature(cfeature.STATES, linewidth=states)
    ax.set_extent(region, crs=crs)
    # Set the proper ticks for a Cartopy map
    ax.set_xticks(xticks, crs=crs)
    ax.set_yticks(yticks, crs=crs)
    ax.xaxis.set_major_formatter(LongitudeFormatter())
    ax.yaxis.set_major_formatter(LatitudeFormatter()) 
开发者ID:fatiando,项目名称:verde,代码行数:23,代码来源:sample_data.py

示例2: _setup_map

# 需要导入模块: from cartopy.mpl import ticker [as 别名]
# 或者: from cartopy.mpl.ticker import LongitudeFormatter [as 别名]
def _setup_map(
    ax, xticks, yticks, crs, region, land=None, ocean=None, borders=None, states=None
):
    """
    Setup a Cartopy map with land and ocean features and proper tick labels.
    """
    import cartopy.feature as cfeature
    from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter

    if land is not None:
        ax.add_feature(cfeature.LAND, facecolor=land)
    if ocean is not None:
        ax.add_feature(cfeature.OCEAN, facecolor=ocean)
    if borders is not None:
        ax.add_feature(cfeature.BORDERS, linewidth=borders)
    if states is not None:
        ax.add_feature(cfeature.STATES, linewidth=states)
    ax.set_extent(region, crs=crs)
    # Set the proper ticks for a Cartopy map
    ax.set_xticks(xticks, crs=crs)
    ax.set_yticks(yticks, crs=crs)
    ax.xaxis.set_major_formatter(LongitudeFormatter())
    ax.yaxis.set_major_formatter(LatitudeFormatter()) 
开发者ID:igp-gravity,项目名称:geoist,代码行数:25,代码来源:fetch_data.py

示例3: plot_map

# 需要导入模块: from cartopy.mpl import ticker [as 别名]
# 或者: from cartopy.mpl.ticker import LongitudeFormatter [as 别名]
def plot_map(geometry, events):
    stamen_terrain = Stamen('terrain-background')
    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1, projection=stamen_terrain.crs)
    ax.add_image(stamen_terrain, 11)

    if events:
        eq = []
        for event in events:
            eq.append([event.longitude, event.latitude])
        eq = np.array(eq).T
        ax.scatter(eq[0], eq[1], label='Event', transform=ccrs.PlateCarree(),
                   color='#555555', edgecolors='k', linewidth=0.3, marker='o', s=10)

    if geometry:
        geom = []
        network = geometry[0].network
        for station in geometry:
            geom.append([station.longitude, station.latitude])
        geom = np.array(geom).T
        ax.scatter(geom[0], geom[1], label=network, transform=ccrs.PlateCarree(),
                   color='#c72c2c', edgecolors='k', linewidth=0.1, marker='v', s=40)

    xmin, xmax = ax.get_xlim()
    ymin, ymax = ax.get_ylim()

    min_point = max_point = TransferProjection(stamen_terrain.crs, ccrs.PlateCarree())
    xmin, ymin = min_point.transfer(xmin, ymin)
    xmax, ymax = max_point.transfer(xmax, ymax)

    xticks = LongitudeLocator(nbins=2)._raw_ticks(xmin, xmax)
    yticks = LatitudeLocator(nbins=3)._raw_ticks(ymin, ymax)

    ax.set_xticks(xticks, crs=ccrs.PlateCarree())
    ax.set_yticks(yticks, crs=ccrs.PlateCarree())
    ax.xaxis.set_major_formatter(LongitudeFormatter(zero_direction_label=True))
    ax.yaxis.set_major_formatter(LatitudeFormatter())

    ax.legend(markerscale=1)
    plt.show() 
开发者ID:SeisNN,项目名称:SeisNN,代码行数:42,代码来源:plot.py

示例4: button_draw

# 需要导入模块: from cartopy.mpl import ticker [as 别名]
# 或者: from cartopy.mpl.ticker import LongitudeFormatter [as 别名]
def button_draw(self, channelname):
        """
        绘图逻辑
        """
        if hasattr(self, 'canvas'):
            self.fig.clear()
        else:
            self.fig = plt.figure('fig', figsize=(6, 4), dpi=100)
            self.canvas = FigureCanvasTkAgg(self.fig, master=self.frame_show)
            self.canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
            self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
            # toolbar = NavigationToolbar2Tk(self.canvas, self.frame_show)
            # toolbar.update()
        # 绘图准备
        PlateCarree = ccrs.PlateCarree()
        self.ax = plt.axes(projection=PlateCarree)
        # 获取数据
        geo_range = self.geo_range.get()
        if self.fy4a_agri_l1.channels[channelname] is None or self.fy4a_agri_l1.geo_range != eval(geo_range):
            self.fy4a_agri_l1.extract(channelname, geo_range=geo_range)
        channel = self.fy4a_agri_l1.channels[channelname]
        # 绘图
        self.ax.add_geometries(provinces_geometrys, PlateCarree,
                               edgecolor='black', facecolor='None')
        lat_S, lat_N, lon_W, lon_E, step = self.fy4a_agri_l1.geo_range
        halfstep = step / 2
        extent = [lon_W - halfstep, lon_E + halfstep,
                  lat_S - halfstep, lat_N + halfstep]
        im = self.ax.imshow(channel, cmap='gray', transform=PlateCarree, origin='upper',
                            extent=extent)
        self.ax.set_xticks(list(range(lon_W, lon_E+1, 10)), PlateCarree)
        self.ax.set_yticks(list(range(lat_S, lat_N+1, 10)), PlateCarree)
        lon_formatter = LongitudeFormatter(zero_direction_label=True)
        lat_formatter = LatitudeFormatter()
        self.ax.xaxis.set_major_formatter(lon_formatter)
        self.ax.yaxis.set_major_formatter(lat_formatter)
        self.ax.coastlines()
        self.fig.colorbar(im, ax=self.ax, shrink=0.7)
        plt.title(channelname)
        self.canvas.draw() 
开发者ID:Mo-Dabao,项目名称:pyMeteo,代码行数:42,代码来源:gui_tkinter.py

示例5: plot_lonlat_map

# 需要导入模块: from cartopy.mpl import ticker [as 别名]
# 或者: from cartopy.mpl.ticker import LongitudeFormatter [as 别名]
def plot_lonlat_map(ax, lon, lat, data, transform, extend=None, cmap="CN_ref", bounds=np.arange(-5,76,5),
                    cbar=True, orientation="vertical",cbar_ticks=None, cbar_ticklabels=None, **kwargs):
    """
    :param ax:cartopy.mpl.geoaxes.GeoAxesSubplot, it should get from cartopy, eg:plt.axes(projection=ccrs.PlateCarree())
    :param lon: lon mesh grid for data units: degree
    :param lat: lat mesh grid for data units: degree
    :param data: radar data ,dims like lat, lon
    :param transform: The transform argument to plotting functions tells Cartopy what coordinate system your data are defined in.
    :param extend: (min_lon, max_lon, min_lat, max_lat), Latitude and longitude range, units:degrees
    :param cmap: str or Colormap, optional, A Colormap instance or registered colormap name. to see cm.py!
    :param min_max: The colorbar range(vmin, vmax). If None, suitable min/max values are automatically chosen by min max of data!
    :param cmap_bins:bins of cmaps, int
    :param cbar: bool, if True, plot with colorbar,
    :param orientation: vertical or horizontal, it is vaild when cbar is True
    :param kwargs: kwargs: other arguments for pcolormesh!
    :return:  pcolor result
    """
    assert isinstance(ax, cartopy.mpl.geoaxes.GeoAxesSubplot), "axes is not cartopy axes!"
    if extend is None:
        min_lon = np.min(lon)
        max_lon = np.max(lon)
        min_lat = np.min(lat)
        max_lat = np.max(lat)
    else:
        min_lon, max_lon, min_lat, max_lat = extend

    ax.set_aspect("equal")
    cmaps = plt.get_cmap(cmap)
    norm = BoundaryNorm(bounds, ncolors=cmaps.N, clip=True)
    pm = ax.pcolormesh(lon, lat, data, transform=transform, cmap=cmap, norm=norm, zorder=4, **kwargs)
    ax.add_feature(cfeature.OCEAN.with_scale('50m'), zorder=0)
    ax.add_feature(cfeature.NaturalEarthFeature('physical', 'land', '50m', \
                                                edgecolor='none', facecolor="white"), zorder=1)
    ax.add_feature(cfeature.LAKES.with_scale('50m'), zorder=2)
    ax.add_feature(cfeature.RIVERS.with_scale('50m'), zorder=3)

    ax.add_feature(cfeature.ShapelyFeature(CN_shp_info.geometries(), transform, \
                                           edgecolor='k', facecolor='none'), linewidth=0.5, \
                   linestyle='-', zorder=5, alpha=0.8)
    parallels = np.arange(int(min_lat), np.ceil(max_lat) + 1, 1)
    meridians = np.arange(int(min_lon), np.ceil(max_lon) + 1, 1)
    ax.set_xticks(meridians, crs=transform)
    ax.set_yticks(parallels, crs=transform)
    lon_formatter = LongitudeFormatter()
    lat_formatter = LatitudeFormatter()
    ax.xaxis.set_major_formatter(lon_formatter)
    ax.yaxis.set_major_formatter(lat_formatter)
    if cbar:
        cb = plt.colorbar(mappable=pm, ax=ax, orientation=orientation)
        if cbar_ticks is None:
            ticks = bounds
        else:
            ticks = cbar_ticks
        cb.set_ticks(ticks)

    if cbar_ticklabels is not None:
        if orientation == "vertical":
            cb.ax.set_yticklabels(cbar_ticklabels)
        else:
            cb.ax.set_xticklabels(cbar_ticklabels)
    return pm 
开发者ID:YvZheng,项目名称:pycwr,代码行数:63,代码来源:RadarPlot.py


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