Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note that the triangulation method can produce weird results (holes in the plot area) when the data spans a plot boundary. For example, as shown above, we need to “fix” the longitude coordinates to go from -180 to 180, or we get a big hole in the plot. This also happens with polar plots, whether we fix the longitudes first or not. A quick example to demonstrate:

Code Block
vname = 'PS'
data = ds[vname]
lon = ds['lon']
lat = ds['lat']

# Plot using triangulation in lat/lon coordinates
data_proj = crs.PlateCarree()  # data is always assumed to be in lat/lon
projections = (crs.PlateCarree(), crs.Orthographic(central_latitude=60))
for plot_proj in projections:
    figure = pyplot.figure()
    ax = figure.add_subplot(111, projection=plot_proj)
    ax.coastlines(linewidth=0.2)
    ax.set_global()
    # Note, we need fix_lon here using this method
    pl = ax.tripcolor(lon, lat, data, transform=data_proj)

...