Cartopy: latitude axis gridlines disappear when stand_lon is changed in namelist.wps
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 498
- Forks
- 178
- PR merge metrics
- No merged PRs in 30d
Description
Hi!
I was unsure whether to share this on the Cartopy Github page, but because the issue occurs due to a change related to WPS, it seemed appropriate to bring it up here.
I am using Cartopy 0.18.0 to plot out my WRF domains on a map. My process is running geogrid.exe and then executing a Python script that calls Cartopy to create the basemap.
In namelist.wps, I have been toying with the stand_lon variable - I would like it to deviate largely from ref_lon. However, when I set the value to be far enough away from ref_lon, run geogrid.exe, then try to plot the basemap with domain boxes overlaid, the latitude axis labels disappear! I want to have a much higher stand_lon so that my domains exclude higher-level terrain (the Rockies).
I use matplotlib.ticker.FixedLocator (Matplotlib 3.3.2) to add specific y-axis labels, but the issue seems to occur regardless of what tick method I choose. This is a specific issue for the y-axis only, as the longitudes on the x-axis seem fine. I did a test to see the extent of the problem by plotting a bunch of latitudes - and there seems to be a cutoff where Cartopy stops adding axis labels. Strange!
Initial figure: stand_lon = -123.5 = ref_lon

Final figure: stand_lon = -88.5, ref_lon = -123.5

Below are some lines of code connected to this problem.
Thanks so much for your help!
- Anthony
` import cartopy.crs as ccrs
from cartopy.feature import BORDERS, COASTLINE, COLORS, LAKES, NaturalEarthFeature
from matplotlib.ticker import FixedLocator, MultipleLocator
import numpy as np
states = NaturalEarthFeature(category='cultural', scale='50m', name='admin_1_states_provinces_shp', facecolor='none')
ax.add_feature(states, edgecolor='k', linewidth=0.3)
ax.add_feature(COASTLINE, edgecolor='k', linewidth=0.5)
ax.add_feature(LAKES, edgecolor='k', facecolor='none', linewidth=0.5)
ax.add_feature(BORDERS, edgecolor='k', linewidth=0.5)
minlon = int(5*np.ceil(lons[(0,0)]/5))
maxlon = int(5*np.ceil(lons[(0,-1)]/5))
minlat = int(4*np.floor(lats[(0,0)]/4))
maxlat = int(4*np.ceil(lats[(-1,0)]/4))
lonticks = range(minlon,maxlon+1,5)
latticks = range(minlat,maxlat+1,4)
glnolabs = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=False, linewidth=1.5, linestyle='--')
glnolabs.xlocator = MultipleLocator(base=5)
glnolabs.ylocator = MultipleLocator(base=5)
gl = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=True, linewidth=1.5, linestyle='--')
gl.top_labels = False
gl.right_labels = False
gl.x_inline = False
gl.y_inline = False
gl.xlocator = FixedLocator(lonticks)
gl.ylocator = FixedLocator([40,41,42,43,44,45,46,47,48,49,50,51,52])
gl.xlabel_style = {'size':lblsz, 'color':'black', 'rotation':0}
gl.ylabel_style = {'size':lblsz, 'color':'black', 'rotation':0}
`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Python Cartopy plotting workflow described in the issue using WRF geogrid.exe output and namelist.wps with different stand_lon values. Compare latitude gridline labels against longitude labels and determine whether the cutoff is in wrf-python or the plotting dependency; done when latitude labels remain visible for the reported projection settings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100