0

Ran into an interesting problem with the behavior of the text annotation functions in cartopy following the documentation which I don't think should be doing this - believe its related to how the text method takes the transform and applies it, perhaps similar to the issue shown here for .annotate (Why the annotate worked unexpected here in cartopy?). Basically no matter what is specified in terms of lat/lon and the transform it always plots at the center point of the plot. Code sample below:

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')])
  • It seems the linked question's answer tells you the solution already. Did you try it? In how far does it not work? – ImportanceOfBeingErnest Aug 07 '18 at 12:46
  • That solution does not work. However, thanks to a suggestion from a colleague worked out that by passing proj' as the 'transform' argument I was making a mistake. The input transform for lat-lon needs to be ccrs.PlateCarre() as otherwise it thinks its an AEA pass. – Xebadir Aug 08 '18 at 16:12
  • 1
    ...which is what the linked question is telling as well. – ImportanceOfBeingErnest Aug 08 '18 at 20:35

0 Answers0