code: def main():
      fig = plt.figure()
      # to get the effect of having just the states without a map "background"
      # turn off the background patch and axes frame
      ax = fig.add_axes(
          [0, 0, 1, 1],
          projection=ccrs.LambertConformal(),
          frameon=False,
      )
      ax.patch.set_visible(False)
  
      ax.set_extent([-125, -66.5, 20, 50], ccrs.Geodetic())
  
      shapename = "admin_1_states_provinces_lakes"
      states_shp = shpreader.natural_earth(
          resolution="110m", category="cultural", name=shapename
      )
  
      lons, lats = sample_data()
  
      ax.set_title(
          "US States which intersect the track of "
          "Hurricane Katrina (2005)"
      )
  
      # turn the lons and lats into a shapely LineString
      track = sgeom.LineString(zip(lons, lats))
  
      # buffer the linestring by two degrees (note: this is a non-physical
      # distance)
      track_buffer = track.buffer(2)
  
      def colorize_state(geometry):
          facecolor = (0.9375, 0.9375, 0.859375)
          if geometry.intersects(track):
              facecolor = "red"
          elif geometry.intersects(track_buffer):
              facecolor = "#FF7E00"
          return {"facecolor": facecolor, "edgecolor": "black"}
  
      ax.add_geometries(
          shpreader.Reader(states_shp).geometries(),
          ccrs.PlateCarree(),
          styler=colorize_state,
      )
  
      ax.add_geometries(
          [track_buffer],
          ccrs.PlateCarree(),
          facecolor="#C8A2C8",
          alpha=0.5,
      )
      ax.add_geometries(
          [track], ccrs.PlateCarree(), facecolor="none", edgecolor="k"
      )
  
      # make two proxy artists to add to a legend
      direct_hit = mpatches.Rectangle((0, 0), 1, 1, facecolor="red")
      within_2_deg = mpatches.Rectangle(
          (0, 0), 1, 1, facecolor="#FF7E00"
      )
      labels = [
          "State directly intersects\nwith track",
          "State is within \n2 degrees of track",
      ]
      ax.legend(
          [direct_hit, within_2_deg],
          labels,
          loc="lower left",
          bbox_to_anchor=(0.025, -0.1),
          fancybox=True,
      )
  
      plt.show()
  
imports: import matplotlib.patches
  import matplotlib.pyplot
  import shapely.geometry
  import cartopy.crs
  import cartopy.io.shapereader
label_desc: Use image node_id 2 for calling a global function with example usage: main() and returns: dict