本文整理匯總了Python中cartopy.mpl.ticker.LatitudeFormatter方法的典型用法代碼示例。如果您正苦於以下問題:Python ticker.LatitudeFormatter方法的具體用法?Python ticker.LatitudeFormatter怎麽用?Python ticker.LatitudeFormatter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cartopy.mpl.ticker
的用法示例。
在下文中一共展示了ticker.LatitudeFormatter方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _setup_map
# 需要導入模塊: from cartopy.mpl import ticker [as 別名]
# 或者: from cartopy.mpl.ticker import LatitudeFormatter [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())
示例2: _setup_map
# 需要導入模塊: from cartopy.mpl import ticker [as 別名]
# 或者: from cartopy.mpl.ticker import LatitudeFormatter [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())
示例3: plot_map
# 需要導入模塊: from cartopy.mpl import ticker [as 別名]
# 或者: from cartopy.mpl.ticker import LatitudeFormatter [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()
示例4: button_draw
# 需要導入模塊: from cartopy.mpl import ticker [as 別名]
# 或者: from cartopy.mpl.ticker import LatitudeFormatter [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()
示例5: plot_lonlat_map
# 需要導入模塊: from cartopy.mpl import ticker [as 別名]
# 或者: from cartopy.mpl.ticker import LatitudeFormatter [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