MCPcopy Index your code
hub / github.com/pydata/xarray / _center_pixels

Function _center_pixels

xarray/plot/dataarray_plot.py:1828–1843  ·  view source on GitHub ↗

Center the pixels on the coordinates.

(x)

Source from the content-addressed store, hash-verified

1826 )
1827
1828 def _center_pixels(x):
1829 """Center the pixels on the coordinates."""
1830 if np.issubdtype(x.dtype, str):
1831 # When using strings as inputs imshow converts it to
1832 # integers. Choose extent values which puts the indices in
1833 # in the center of the pixels:
1834 return 0 - 0.5, len(x) - 0.5
1835
1836 try:
1837 # Center the pixels assuming uniform spacing:
1838 xstep = 0.5 * (x[1] - x[0])
1839 except IndexError:
1840 # Arbitrary default value, similar to matplotlib behaviour:
1841 xstep = 0.1
1842
1843 return x[0] - xstep, x[-1] + xstep
1844
1845 # Center the pixels:
1846 left, right = _center_pixels(x)

Callers 1

imshowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…