Why some data is missing on a figure when I define the axes? My dataset is a DataArray and some values are masked

27 Views Asked by At

I would like to be able to define my axis and not lose information. Currently, I am missing the last data point in both dimensions I defined (see figure).

Two panels with the same data, but the axes are different. On the left panel, the axes are not defined and thus represent the size of the data. On the right panel, the axes are defined but we are missing the last data point in each dimension.

DATA = xr.DataArray(np.random.rand(74,13),dims=('section','lag'))
DATA = DATA.where(DATA>.98,drop=True)

fig,(ax0,ax1) = plt.subplots(1,2,figsize=(10,2))

ax0.pcolor(DATA)
ax0.set(title='Axes not defined')

ax1.pcolor(DATA.lag, DATA.section, DATA)
ax1.set(title='Axes defined')

plt.show()
1

There are 1 best solutions below

0
Anne Sophie On

One way around this: Since my data is a DataArray, I could redefine the coordinates and plot it with xarray:

DATA.assign_coords(section=a,lag=b)
DATA.plot.pcolor()