You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature request] Adding ticks to geographic plots #125
Ah wait I read this wrong, you want the ticklens not the grid to change.
Yes, ticks in geographic plots are used more frequently than gridlines, at least in my field. They help keep the map clean and visually appealing by avoiding clutter from multiple gridlines.
In some cases, we need to overlap contours. If we use gridlines simultaneously, there will be toooo many lines in the map.
TypeError: Cannot label AzimuthalEquidistant gridlines. Only PlateCarree gridlines are currently supported.
I think the labelling is non-trivial. This error is produced by cartopy when I attempt to force labeling on non PlateCarree projections. Will do some more digging to see if this can be achieved.
I'm super confused how the tickers are handled by matplotlib. The issue seems that for the projection above that the range is so big that it attempts to parse it evenly which generates too many ticks for matplotlib too handle. I attempted to limit these by overriding the ticker, but most function internally to matplotlib revert this conversion by making its own ticker which prevent passing parameters that could limit the tick locations and hence the error.
I am not too familiar with the internals of cartopy and how they divide these ranges. Luke also ran into this issue judging from the link above.
TypeError: Cannot label AzimuthalEquidistant gridlines. Only PlateCarree gridlines are currently supported.
I think the labelling is non-trivial. This error is produced by cartopy when I attempt to force labeling on non PlateCarree projections. Will do some more digging to see if this can be achieved.
Cartopy does not seem to support adding ticks for non-rectangular projections. I'm not sure whether it's possible to add ticks in a polar projection. However, we can now use ax.format(lontick=True, lattick=True) with ccrs.PlateCarree(), which I believe meets the needs of most use cases :-)
Are there any flat projections missing from the PR? See the function _is_flat_projection. Currently I have these:
flat_names= [
"PlateCarree",
"Mercator",
"LambertCylindrical",
"Miller",
"Robinson",
"Mollweide",
"EqualEarth",
]
flat_names_basemap= [
"basemap",
"merc",
"cyl",
"rectilinear",
"rect",
"tmerc",
"mill",
"unknown", # not sure why this is created on basemap but assume it is flat
]
Are there any flat projections missing from the PR? See the function _is_flat_projection. Currently I have these:
flat_names = [
"PlateCarree",
"Mercator",
"LambertCylindrical",
"Miller",
"Robinson",
"Mollweide",
"EqualEarth",
]
flat_names_basemap = [
"basemap",
"merc",
"cyl",
"rectilinear",
"rect",
"tmerc",
"mill",
"unknown", # not sure why this is created on basemap but assume it is flat
]
I am not sure what "flat projection" refers to, but similar to Robinson, there are Hammer, Aitoff. You can find more in this cartopy projection list
# For cartopy
if hasattr(proj, "name"):
name = proj.name.lower()
# For basemap:
else:
name = proj.projection.lower()
return any(
name == flat_name.lower() for flat_name in flat_names + flat_names_basemap
)
I am a bit confused about this paragraph. proj.name.lower() always seems to return "unknown" in my case.
Activity
cvanelteren commentedon Mar 16, 2025
I believe this is already possible:
cvanelteren commentedon Mar 16, 2025
Or more succinctly:
cvanelteren commentedon Mar 16, 2025
But perhaps I am missing something (not a geoscientist ;-)).
cvanelteren commentedon Mar 16, 2025
Ah wait I read this wrong, you want the ticklens not the grid to change.
664787022 commentedon Mar 16, 2025
Yes, ticks in geographic plots are used more frequently than gridlines, at least in my field. They help keep the map clean and visually appealing by avoiding clutter from multiple gridlines.
In some cases, we need to overlap contours. If we use gridlines simultaneously, there will be toooo many lines in the map.
cvanelteren commentedon Mar 16, 2025
cvanelteren commentedon Mar 16, 2025
Is the attached img in #126 what you had in mind?
664787022 commentedon Mar 16, 2025
Yes! It looks great! but im not sure if it goes well when using polar axes. For example uplot.subplot(proj="aeqd")
cvanelteren commentedon Mar 16, 2025
Do you have an example of how that would look like for polar axes? The ticks won't be equally spaced I am assuming.
cvanelteren commentedon Mar 16, 2025
I think the labelling is non-trivial. This error is produced by cartopy when I attempt to force labeling on non PlateCarree projections. Will do some more digging to see if this can be achieved.
cvanelteren commentedon Mar 16, 2025
I'm super confused how the tickers are handled by matplotlib. The issue seems that for the projection above that the range is so big that it attempts to parse it evenly which generates too many ticks for matplotlib too handle. I attempted to limit these by overriding the ticker, but most function internally to matplotlib revert this conversion by making its own ticker which prevent passing parameters that could limit the tick locations and hence the error.
I am not too familiar with the internals of cartopy and how they divide these ranges. Luke also ran into this issue judging from the link above.
Input is appreciated on the PR.
664787022 commentedon Mar 17, 2025
Cartopy does not seem to support adding ticks for non-rectangular projections. I'm not sure whether it's possible to add ticks in a polar projection. However, we can now use ax.format(lontick=True, lattick=True) with ccrs.PlateCarree(), which I believe meets the needs of most use cases :-)
cvanelteren commentedon Mar 17, 2025
Are there any flat projections missing from the PR? See the function
_is_flat_projection. Currently I have these:664787022 commentedon Mar 17, 2025
I am not sure what "flat projection" refers to, but similar to Robinson, there are Hammer, Aitoff. You can find more in this cartopy projection list
664787022 commentedon Mar 17, 2025
I am a bit confused about this paragraph. proj.name.lower() always seems to return "unknown" in my case.
works
beckermr commentedon Mar 17, 2025
I think "flat" here is not a geometric statement. Instead what is meant is "a projection that you plot on a rectangle"?
If so we should find the proper term and use it in the code.
cvanelteren commentedon Mar 17, 2025
I used rectilinear now and modified the checks that should be name independent.
cvanelteren commentedon Mar 18, 2025
@664787022 with flat I referred to rectilinear, does my previous remark make sense now?
cvanelteren commentedon Mar 20, 2025
Feature is added in main. Will draft a release tag.