Unexpected polygon when plot the density isopycnal by contour function

I would like to plot the contour of a 2D density xarray.DataArray dataset. The dataset is binned in dimensions (y,x) with coordinates (lat,lon), somehow the lat is not in alignment in the row and the lon is not in alignment in the column. So, I get the annoying polygons in my plot. Does anyone know how to fix this? By the way, I have tried to sort it before plotting, which doesn’t work ;(


1 Like

I find a way to fix the problem now. It may not be a perfect way to do so, but easy and simple. First, sort the data by the longitude value. Next, crop the boundary values, then the dataset will be orderly.
If anyone has a better idea, please let me know. :wink:

1 Like