my trouble is that i’m doing a non-regular mesh, and when i make a plot with scatter the points the picture shows this.
scatter plot of coordinates
But when i want make a pcolormesh, the borders looks distorsionated
pcolormesh
This is the code
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import cartopy.mpl.geoaxes
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import numpy as np
region=[-75,-68,-38,-29]
fig = plt.figure()
# iniciliazar mapa
ax=fig.add_subplot(111,projection=ccrs.PlateCarree())
ax.set_extent(region, crs=ccrs.PlateCarree())
ax.add_feature(cfeature.BORDERS)
ax.add_feature(cfeature.COASTLINE)
ax.add_feature(cfeature.LAND, edgecolor='black')
ax.add_feature(cfeature.OCEAN)
ax.add_feature(cfeature.LAKES, edgecolor='black')
ax.add_feature(cfeature.RIVERS)
axins = inset_axes(ax, width="30%", height="30%", loc="upper left",
axes_class=cartopy.mpl.geoaxes.GeoAxes,
axes_kwargs=dict(projection=cartopy.crs.Orthographic(central_longitude=-70, central_latitude=-30)))
axins.add_feature(cartopy.feature.COASTLINE)
axins.stock_img()
# Dibujar un rectángulo alrededor de Chile en el inset usando plot
rect_lons = [-75, -66, -66, -75, -75] # Longitudes para el rectángulo
rect_lats = [-46, -46, -17, -17, -46] # Latitudes para el rectángulo
axins.plot(rect_lons, rect_lats, color='red', linestyle='-', linewidth=1.2,transform=ccrs.PlateCarree())
text='Chile'
axins.text(-75, -30, text, fontsize=10, ha='right', transform=ccrs.PlateCarree())
gl = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=True,
linewidth=1, color='gray', alpha=0.5, linestyle='--')
gl.right_labels = False
gl.top_labels = False
# ax.scatter(lon_flat,lat_flat,transform=ccrs.PlateCarree(),color='red',s=2)
ax.pcolormesh(X_grid, Y_grid, np.zeros(X_grid.shape), cmap='binary',transform=ccrs.PlateCarree(),edgecolors='k', linewidths=0.1,antialiased=True,shading='auto')
plt.show()
I want that the pcolormesh figure shows the mesh as the scatter