matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
779 stars 392 forks source link

weird contour plot with polar projections #118

Closed bssrdf closed 8 years ago

bssrdf commented 11 years ago

Hi

I am making Polar Stereographic Projection maps of some climate model outputs. For some of these data, the plot looks weird. For example, in this figure (https://dl.dropboxusercontent.com/u/45427012/ALB_ERR.png), only two color contours showed up while the actual data should span much wider range. Furthermore, a large portion of the region should be blank since the data are masked out by netcdf module already (they are undefined). You can find the script and dataset which generated the figure at here

python script https://dl.dropboxusercontent.com/u/45427012/plot_albice_error.py

data (netcdf4), you'll need netcdf module to open it. https://dl.dropboxusercontent.com/u/45427012/alb.nc4

BTW, I am using basemap-1.0.6 with matplotlib-1.2.1 on py2.7.

Any help will be much appreciated.

Bin Zhao

guziy commented 11 years ago

You have to use m.contourf and not plt.contourf. http://nbviewer.ipython.org/urls/raw.github.com/guziy/PyNotebooks/master/basemap_demo.ipynb as for the range, it is not that wide, you have very few points less than 0.6, and the min,max median values are 0.538289, 0.828474, 0.824061095715 respectively. It is possible that some points get lost due to interpolation, since mask + (number) = mask. You could use pcolormesh, but before you have to select data and lon, lats for the corresponding hemisphere. I am actually surprised m.contourf works (it seems correctly) with the data. If you plot global data use global projections like robin for example...

Oleksandr (Sasha) Huziy

WeatherGod commented 8 years ago

Closing the issue since there has been no follow-up (assumed that the advice was valid).