SciTools / cartopy

Cartopy - a cartographic python library with matplotlib support
https://scitools.org.uk/cartopy/docs/latest
BSD 3-Clause "New" or "Revised" License
1.41k stars 359 forks source link

Gridlines threshold for polar stereographic plots using matplotlib #1343

Open tomduck opened 5 years ago

tomduck commented 5 years ago

It was suggested by ajdawson on stackoverflow that I submit this as an Issue.

When plotting with matplotlib and cartopy's NorthPolarStereo projection, the constant-latitude gridlines (parallels) are not smooth circles.

Here is a minimum working example:

from matplotlib import pyplot
import cartopy.crs

ax = pyplot.axes(projection=cartopy.crs.NorthPolarStereo())
ax.set_extent((-180, 180, 60, 90), crs=cartopy.crs.PlateCarree())
ax.gridlines()

pyplot.show()

Here is the image produced:

Polar stereographic gridlines plot

As you can see, the parallels are a series of straight-line segments between points.

The solution proposed was to reduce the size of the private _threshold variable in the projection; e.g.:

hacked_proj = cartopy.crs.NorthPolarStereo()
hacked_proj._threshold /= 100.

It would be useful to have a public interface that allows users to accomplish the same thing.

ajdawson commented 5 years ago

This specific problem can be worked around in a much nicer way, as shown in https://stackoverflow.com/a/57098368/1867427 (go accept that answer instead of mine!).

However, I think there is still a general issue of threshold not being appropriate in some circumstances, for example https://stackoverflow.com/questions/40270990/cartopy-higher-resolution-for-great-circle-distance-line/40279430#40279430.

QuLogic commented 4 years ago

This is generally a consequence of #8.