# Unexpected polygon when plot the density isopycnal by contour function

**URL:** <https://forum.access-hive.org.au/t/unexpected-polygon-when-plot-the-density-isopycnal-by-contour-function/988>\
**Category:** Technical\
**Tags:** python\
**Created:** [13 July 2023 04:39 UTC](https://forum.access-hive.org.au/t/unexpected-polygon-when-plot-the-density-isopycnal-by-contour-function/988 "2023-07-13T04:39:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zijin](https://avatars.discourse-cdn.com/v4/letter/z/94ad74/32.png) [@Zijin](https://forum.access-hive.org.au/u/Zijin)\
**Post date:** [13 July 2023 04:39 UTC](https://forum.access-hive.org.au/t/unexpected-polygon-when-plot-the-density-isopycnal-by-contour-function/988/1 "2023-07-13T04:39:20Z")

</div>

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 ;(

 ![image](https://us1.discourse-cdn.com/flex020/uploads/access1/original/1X/8b7662e26a5b0cdaf7ecc11ea341f5aa57ec2cd1.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/access1/original/1X/03996b7318364bbcf8acfd6e6546662de0a035c6.jpeg)

---

<div class="post-metadata">

**Author:** ![Zijin](https://avatars.discourse-cdn.com/v4/letter/z/94ad74/32.png) [@Zijin](https://forum.access-hive.org.au/u/Zijin)\
**Post date:** [19 July 2023 00:37 UTC](https://forum.access-hive.org.au/t/unexpected-polygon-when-plot-the-density-isopycnal-by-contour-function/988/2 "2023-07-19T00:37:53Z")

</div>

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. 😉
