[Matplotlib-users] plotting netcdf data on a map in matplotlib

Jason Snyder jmssnyder at ucdavis.edu
Thu Mar 30 16:49:11 EDT 2017

The main issue I have is that the data does not plot properly.  There
evidently is an issue of matching coordinates in the data versus the map.
I am sending the netcdf file along with the script.  I am not sure how to
plot a map with data without using basemap since this is what provides the
continental outlines.  If you know of any way I can plot this data using
matplotlib successful let me know.


On Thu, Mar 30, 2017 at 8:38 PM, Jody Klymak <jklymak at uvic.ca> wrote:

> I’m not an expert on cartopy.
> 1) can you plot this data w/o using basemap?
> 2) why do you have the “squeeze” command in there?
> 3) I’m not clear what the problem is with your image from the snippet you
> sent.   Is it just an issue with the longitude wrapping?  Some projections
> demand longitude must be between -180 and 180. i.e.
> lon[lon>=180]=lon[lon>=180]-360.  You may also need to re-order your
> longitude and data so that longitude is monotonically increasing.
> 4) I recommend xarray when dealing w/ netcdf files, though maybe that is
> overkill for your problem.
> A minimal working example with a link to the bad data always helps.
> I’m sure with a bit of experimentation and use of google you can get this
> working.
> i.e.
> http://stackoverflow.com/questions/13856123/setting-up-
> a-map-which-crosses-the-dateline-in-cartopy
> Cheers,   Jody

Jason Snyder PhD
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170330/300da166/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2017032800.nc.tar.gz
Type: application/x-gzip
Size: 30496 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170330/300da166/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testnetcdf.py
Type: text/x-python
Size: 28 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170330/300da166/attachment-0001.py>

More information about the Matplotlib-users mailing list