Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contourf plot with Robinson projection produces wrong results dependent on central_longitude #2457

Open
schlunma opened this issue Oct 22, 2024 · 1 comment

Comments

@schlunma
Copy link

schlunma commented Oct 22, 2024

Description

Using contourf produces wrong plots with the Robinson projection depending on the setting of central_longitude.

Code to reproduce

import iris
import iris.plot
import matplotlib.pyplot as plt
import cartopy.crs as ccrs

cube = iris.load_cube(path)

fig = plt.figure()
projection = ccrs.Robinson(central_longitude=0.0)
axes = fig.add_subplot(projection=projection)
axes.contourf(cube.coord('longitude').points, cube.coord('latitude').points, cube.data, cmap='bwr', levels=12, transform=ccrs.PlateCarree())

With this dataset, this produces the wrong

grafik

With this dataset, this produces the correct

grafik

Note that these plots should look very different. The extensions .txt need to be removed for the files.

Changing to central_longitude=10.0 in the code example swaps this behavior: the first example now looks fine and the second one looks weird. This also seem to depend on the number of levels.

Using pcolormesh creates nicely looking plots in all cases.

Full environment definition

Operating system

Cartopy version

0.23.0

conda list

env.txt

pip list

pip.txt

@schlunma schlunma changed the title Contourf plot with Robinson projection produces wrongresults dependent on central_longitude Contourf plot with Robinson projection produces wrong results dependent on central_longitude Oct 22, 2024
@rcomer
Copy link
Member

rcomer commented Oct 23, 2024

Thanks @schlunma, unfortunately this is a long-standing known problem, and hard to track down. One possible work-around is to use the transform_first option, which should also make it plot faster.
https://scitools.org.uk/cartopy/docs/latest/gallery/scalar_data/contour_transforms.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants