文字Cartopy注解放错位置

时间:2018-08-07 12:30:47

标签: matplotlib cartopy

在我认为不应该这样做的文档之后,cartopy中的文本注释功能的行为遇到了一个有趣的问题-认为其与text方法如何进行转换并应用它有关,也许类似于此处显示的.annotate(Why the annotate worked unexpected here in cartopy?)问题。基本上,无论是根据纬度/经度和变换指定什么,它始终都会绘制在图的中心点。下面的代码示例:

import cartopy.crs as ccrs
import cartopy.feature as cfeature
import cartopy.io.shapereader as shpreader
from matplotlib.colors import BoundaryNorm
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import matplotlib.patheffects as path_effects

def basic_map(proj):
  fig = plt.figure(figsize=(12, 8))
  view = fig.add_axes([0, 0, 1, 1], projection=proj)
  view.set_extent([-120, -73, 23, 50])
  view.add_feature(cfeature.STATES.with_scale('50m'))
  view.add_feature(cfeature.OCEAN.with_scale('50m'),facecolor='white')
  view.add_feature(cfeature.COASTLINE.with_scale('50m'))
  view.add_feature(cfeature.BORDERS, linestyle=':')
  return fig, view

proj = ccrs.AlbersEqualArea(central_longitude=-97.0000,      central_latitude=38.0000)
fig, view = basic_map(prod)
view.text(-70,41, 'Northeast', color='black', fontsize=20, fontweight='bold',transform=proj,
      path_effects=[path_effects.withSimplePatchShadow(),path_effects.PathPatchEffect(edgecolor='black', linewidth=0.6,facecolor='black')])

0 个答案:

没有答案