-
Notifications
You must be signed in to change notification settings - Fork 359
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 producing maps with blank spots #1131
Milestone
Comments
The contours can be reduced to these two broken paths: import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import matplotlib.path as mpath
import numpy as np
verts17 = np.array([
[-170. , -90. ],
[-160. , -90. ],
[-150. , -90. ],
[-140. , -90. ],
[-130. , -90. ],
[-120. , -90. ],
[-110. , -90. ],
[-100. , -90. ],
[ -90. , -90. ],
[ -80. , -90. ],
[ -70. , -90. ],
[ -60. , -90. ],
[ -50. , -90. ],
[ -40. , -90. ],
[ -30. , -90. ],
[ -20. , -90. ],
[ -10. , -90. ],
[ 0. , -90. ],
[ 10. , -90. ],
[ 20. , -90. ],
[ 30. , -90. ],
[ 40. , -90. ],
[ 50. , -90. ],
[ 60. , -90. ],
[ 70. , -90. ],
[ 80. , -90. ],
[ 90. , -90. ],
[ 100. , -90. ],
[ 110. , -90. ],
[ 120. , -90. ],
[ 130. , -90. ],
[ 140. , -90. ],
[ 150. , -90. ],
[ 160. , -90. ],
[ 170. , -90. ],
[ 180. , -90. ],
[ 180. , -88.06480482],
[ 170. , -88.19689778],
[ 160. , -88.26258068],
[ 150. , -88.26947457],
[ 140. , -88.21430546],
[ 130. , -88.08098516],
[ 120. , -87.8311056 ],
[ 110. , -87.37441191],
[ 100. , -86.46208528],
[ 90. , -84.10837483],
[ 84.3443839 , -80. ],
[ 82.5282601 , -70. ],
[ 83.31809409, -60. ],
[ 85.45458246, -50. ],
[ 89.08554991, -40. ],
[ 90. , -38.46802366],
[ 99.71787765, -30. ],
[ 100. , -29.86852629],
[ 110. , -27.99419447],
[ 120. , -27.67466329],
[ 130. , -28.10693902],
[ 140. , -29.35305703],
[ 143.03836208, -30. ],
[ 150. , -31.7583954 ],
[ 160. , -35.13382265],
[ 170. , -39.20356446],
[ 171.74123963, -40. ],
[ 180. , -44.25336715],
[ 180. , -40. ],
[ 180. , -39.90678111],
[ 170. , -35.33327859],
[ 160. , -31.27633115],
[ 156.2191454 , -30. ],
[ 150. , -28.21691104],
[ 140. , -26.10059642],
[ 130. , -24.84924035],
[ 120. , -24.29664457],
[ 110. , -24.2357849 ],
[ 100. , -25.33754215],
[ 90. , -29.99709329],
[ 89.99691751, -30. ],
[ 84.02835495, -40. ],
[ 80.73076516, -50. ],
[ 80. , -53.01792348],
[ 78.30311067, -60. ],
[ 75.77262267, -70. ],
[ 70.71336012, -80. ],
[ 70. , -81.11643952],
[ 60. , -86.53485986],
[ 50. , -87.81217178],
[ 40. , -88.36391949],
[ 30. , -88.65812942],
[ 20. , -88.82994152],
[ 10. , -88.93226075],
[ 0. , -88.98936602],
[ -10. , -89.01312918],
[ -20. , -89.00890267],
[ -30. , -88.97771693],
[ -40. , -88.91670403],
[ -50. , -88.81813456],
[ -60. , -88.66642441],
[ -70. , -88.43064893],
[ -80. , -88.04423025],
[ -90. , -87.33787453],
[-100. , -85.72495289],
[-109.30108519, -80. ],
[-110. , -79.72032435],
[-120. , -73.87360322],
[-124.00085117, -70. ],
[-130. , -66.47702774],
[-139.57861887, -60. ],
[-140. , -59.7801689 ],
[-150. , -54.8341225 ],
[-159.48461603, -50. ],
[-160. , -49.76606705],
[-170. , -45.03326184],
[-179.80462939, -40. ],
[-180. , -39.90678111],
[-180. , -40. ],
[-180. , -44.25336715],
[-170. , -49.21772383],
[-168.3447695 , -50. ],
[-160. , -54.49737642],
[-150. , -59.40162374],
[-148.78879731, -60. ],
[-140. , -66.28648692],
[-134.09548541, -70. ],
[-130. , -76.33997544],
[-126.12935689, -80. ],
[-130. , -82.80062298],
[-140. , -85.71941512],
[-150. , -86.8803473 ],
[-160. , -87.48675446],
[-170. , -87.84430274],
[-180. , -88.06480482],
[-180. , -90. ],
[-170. , -90. ]])
codes17 = np.array([1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 79])
bad_path17 = mpath.Path(verts17, codes17)
verts18 = np.array([
[-110. , 49.76654914],
[-100. , 48.06726757],
[ -90. , 47.83070886],
[ -80. , 49.51041661],
[ -78.48184154 , 50. ],
[ -70. , 55.59874175],
[ -62.92912972 , 60. ],
[ -60. , 68.98354974],
[ -59.48362882 , 70. ],
[ -60. , 71.96086464],
[ -65.36243675 , 80. ],
[ -60. , 82.08541582],
[ -50. , 84.26827105],
[ -40. , 85.41441829],
[ -30. , 86.05775411],
[ -20. , 86.40296264],
[ -10. , 86.53295542],
[ 0. , 86.46670029],
[ 10. , 86.16593423],
[ 20. , 85.49503981],
[ 30. , 84.04405843],
[ 40. , 80.13007872],
[ 40.1755513 , 80. ],
[ 48.01772332 , 70. ],
[ 50. , 68.09459195],
[ 55.47216536 , 60. ],
[ 60. , 56.42708207],
[ 67.37826371 , 50. ],
[ 70. , 48.69264769],
[ 80. , 44.39058248],
[ 90. , 41.37291304],
[ 100. , 40.12749416],
[ 110. , 41.22341995],
[ 120. , 44.60261529],
[ 130. , 49.16288744],
[ 131.74881042 , 50. ],
[ 140. , 54.98074439],
[ 150. , 59.0727081 ],
[ 153.35828768 , 60. ],
[ 160. , 62.93157679],
[ 170. , 65.30146242],
[ 180. , 66.36452994],
[ 180. , 70. ],
[ 180. , 80. ],
[ 180. , 90. ],
[ 170. , 90. ],
[ 160. , 90. ],
[ 150. , 90. ],
[ 140. , 90. ],
[ 130. , 90. ],
[ 120. , 90. ],
[ 110. , 90. ],
[ 100. , 90. ],
[ 90. , 90. ],
[ 80. , 90. ],
[ 70. , 90. ],
[ 60. , 90. ],
[ 50. , 90. ],
[ 40. , 90. ],
[ 30. , 90. ],
[ 20. , 90. ],
[ 10. , 90. ],
[ 0. , 90. ],
[ -10. , 90. ],
[ -20. , 90. ],
[ -30. , 90. ],
[ -40. , 90. ],
[ -50. , 90. ],
[ -60. , 90. ],
[ -70. , 90. ],
[ -80. , 90. ],
[ -90. , 90. ],
[-100. , 90. ],
[-110. , 90. ],
[-120. , 90. ],
[-130. , 90. ],
[-140. , 90. ],
[-150. , 90. ],
[-160. , 90. ],
[-170. , 90. ],
[-180. , 90. ],
[-180. , 80. ],
[-180. , 70. ],
[-180. , 66.36452994],
[-170. , 66.49729491],
[-160. , 65.73294484],
[-150. , 63.78287603],
[-140.53635295 , 60. ],
[-140. , 59.88238149],
[-130. , 57.2018102 ],
[-120. , 53.72014009],
[-110.8967899 , 50. ],
[-110. , 49.76654914],
])
codes18 = np.array([1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 79])
bad_path18 = mpath.Path(verts18, codes18)
lon_0 = 0
# plot with cartopy
ax = plt.axes(projection=ccrs.Mollweide(central_longitude=lon_0))
ax.set_global()
patch = mpatches.PathPatch(bad_path17, facecolor='C0', edgecolor='none',
label='17 0', transform=ccrs.PlateCarree())
ax.add_patch(patch)
ax.scatter(verts17[:, 0], verts17[:, 1], color=f'C1', marker='x',
transform=ccrs.PlateCarree(), label='17 0')
patch = mpatches.PathPatch(bad_path18, facecolor='C2', edgecolor='none',
label='18 2', transform=ccrs.PlateCarree())
ax.add_patch(patch)
ax.scatter(verts18[:, 0], verts18[:, 1], color=f'C3', marker='x',
transform=ccrs.PlateCarree(), label='18 2')
ax.legend()
plt.show() The scatter points do appear in the right place, so it seems there is a problem when stitching the transformed points back into shape somehow, at least for the top one. |
Even shorter reproducer on the top one: verts18 = np.array([
[-110., 50.],
[ 0., 80.],
[ 0., 90.],
[-180., 90.],
[-180., 70.],
[-110., 50.],
])
codes18 = np.array([1, 2, 2, 2, 2, 79]) |
This was referenced Oct 13, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
I work on a geology package and we would like to switch from Basemap to cartopy. I am trying to plot a contour map with the magnetic field strength. This works correctly in Basemap's contourf, but with the same data in cartopy there are mysterious blank spots in the plot.
Image produced by basemap:
![image](https://user-images.githubusercontent.com/1836578/46097568-291f8280-c177-11e8-8dab-e3116458304b.png)
Image produced by cartopy:
![image](https://user-images.githubusercontent.com/1836578/46097587-30469080-c177-11e8-909a-9b9fdf0f2c34.png)
Code to reproduce
Full code (including data) in Jupyter html:
cartopy_plotting.html.zip
Full code in .ipynb form:
cartopy_plotting.ipynb.zip
Traceback
Full environment definition
Operating system
OSX High Sierra 10.13.6
Cartopy version
0.16.1
conda list
pip list
The text was updated successfully, but these errors were encountered: