Skip to content
Snippets Groups Projects
Commit 9229f9a0 authored by Aaron Spring's avatar Aaron Spring
Browse files

draw_lon_lat_labels

parent f2190506
No related branches found
No related tags found
No related merge requests found
......@@ -42,4 +42,4 @@ dependencies:
- pre-commit
- pytest-lazy-fixture
- pytest-tldr
+ git+https://github.com/dask/dask-labextension.git
- git+https://github.com/dask/dask-labextension.git
......@@ -85,17 +85,6 @@ class CartopyMap(object):
), (xda.ndim, xda.dims)
single_plot = True if xda.ndim == 2 else False
stereo_maps = (
ccrs.Stereographic,
ccrs.NorthPolarStereo,
ccrs.SouthPolarStereo,
)
if isinstance(proj, stereo_maps):
raise ValueError(
'Not implemented, see'
'https://github.com/luke-gregor/xarray_tools/accessors.py#L222'
)
# find whether curv or not
curv = False
lon = None
......@@ -110,6 +99,10 @@ class CartopyMap(object):
assert lon, (lon, xda.coords)
assert lat, (lat, xda.coords)
if plot_lon_lat_axis:
draw_labels = True
else:
draw_labels = False
if proj != ccrs.PlateCarree():
plot_lon_lat_axis = False
......@@ -160,6 +153,12 @@ class CartopyMap(object):
if plot_lon_lat_axis:
_set_lon_lat_axis(axes, proj)
else:
gl = axes.gridlines(draw_labels=draw_labels)
gl.top_labels = False
gl.right_labels = False
gl.xlines = False
gl.ylines = False
if single_plot:
if ax is None:
......@@ -179,7 +178,7 @@ def _rm_singul_lon(ds, lon='lon', lat='lat'):
lons = ds[lon].values
fixed_lons = lons.copy()
for i, start in enumerate(np.argmax(np.abs(np.diff(lons)) > 180, axis=1)):
fixed_lons[i, start + 1 :] += 360
fixed_lons[i, start + 1:] += 360
lons_da = xr.DataArray(fixed_lons, ds[lat].coords)
ds = ds.assign_coords({lon: lons_da})
return ds
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment