cartopy icon indicating copy to clipboard operation
cartopy copied to clipboard

Deprecate old lat/lon tick label formatters

Open lbdreyer opened this issue 6 years ago • 6 comments

We have two (2) longitude and latitude tick formatters.

cartopy.mpl.gridliner.LONGITUDE_FORMATTER which is ~5 years old and cartopy.mpl.ticker.LongitudeFormatter which is ~ 4 years old

The newer one is better as it allows the user to modify the number format, etc. I'm not sure why the old one wasn't removed when the new one was added, the code is so similar!

I think we should deprecate the older version in preference for the newer one and update all the places it gets used (e.g. in the cartopy course)

lbdreyer avatar May 01 '18 16:05 lbdreyer

Would it be better to use matplotlib's deprecation infrastructure rather than adding our own?

dopplershift avatar May 01 '18 18:05 dopplershift

@dopplershift Would it be better to use matplotlib's deprecation infrastructure rather than adding our own?

Do you just mean using mplDeprecation, like https://github.com/matplotlib/matplotlib/pull/7723 ? Or is there more to it ? I'm no expert, but I can't find anything about managing deprecation in their developer guide pages.

pp-mo avatar May 02 '18 09:05 pp-mo

Matplotlib has a matplotlib.cbook.deprecated decorator for marking classes/functions as deprecated.

dopplershift avatar May 02 '18 14:05 dopplershift

@lbdreyer - any chance you've got some time to spin this back up? Would be good to target this for v0.18.

pelson avatar Dec 05 '18 01:12 pelson

Wouldn't this PR be suitable for the next release?

I think the pitfall mentioned in https://github.com/SciTools/cartopy/pull/401#issuecomment-39194824 is no longer relevant in version 0.18:

https://github.com/SciTools/cartopy/blob/178a15e39d085758832d30aa9f77f34f708a7d1e/lib/cartopy/mpl/gridliner.py#L194-L208

Matplotlib's ScalarFormatter has always had the same limitation (you cannot re-use ScalarFormatter on multiple axes), but since ScalarFormatter is meant to be enabled automatically / untouched by 99.9% of users very few people run into this problem (and presumably being axis-specific allows you to design a more intelligent auto-formatting algorithm).

Now that version 0.18 makes LatitudeFormatter and LongitudeFormatter the default formatters for gridline labels, very few users will have to work with them directly / run into this problem.

One thing you could also do is add xformatter_kw and yformatter_kw keyword argument dictionary-arguments to cartopy.mpl.GridLiner(). These arguments would get passed to LatitudeFormatter and LongitudeFormatter on instantiation, which lets users customize the tick format and further avoids requiring people to work with the classes directly. Matplotlib uses this _kw convention in several places, e.g. pyplot.subplots().

lukelbd avatar May 11 '20 05:05 lukelbd

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Apr 08 '24 16:04 CLAassistant