[Matplotlib-users] Wrong projection?
Hi all! I've tried to plot some (sea ice thickness, snow freeboard etc.) netcdf-data on Antarctic waters but there seems to be something funny here since the plot is kind of cut in half or something. from Scientific.IO.NetCDF import NetCDFFile # Also numpy as np, Basemap etc, matplotlib as plt. F = NetCDFFile('data.nc','r')lat = F.variables['nav_lat'][:,0]lon = F.variables['nev_lon'][0,:]data = np.ma.masked_where(np.isnan(F.variables['iice_hid'][0,2,:,:]), F.variables['iice_hid'][0,2,:,:])m = Basemap(projection='spaeqd',boundinglat=-50,lon_0=180,resolution='l')lons, lats = np.meshgrid(lon,lat)fig = plt.figure()m.pcolormesh(lons,lats,data,latlon=True,vmin=0,vmax=2.3)m2.drawcoastlines()plt.show() Unfortunately I can't provide any data, but the dimensions are:x=1442; y=1021; icethi(=layers)=5; time_counter=1Longitudes are like (y,x), in degrees_east, min -180 and max 180Latitudes are (y,x), in degrees_north, min -77, max 89Data (the one to draw) is (time_counter,icethi,y,x). Without meshgrid there is a RuntimeError: Buffer lengths not the same. Also I've tried many other projections like spstere, laea,splaea... With addcyclic the result looks exactly the same so that can't be the problem either. The netcdf file doesn't contain any more information about coordinate systems or projection, just that lon and lat model is in "Default grid" what ever that means. I would be very thankful if anyone can help me or give me a glue, from where to look for a solution Cheers, Bill! -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Wrong projection?
Hi Bill, I've created a class for using the IBCAO with Basemap in the _Arctic_ that might be useful for you, it is located here: http://scipy-central.org/item/75/0/ibcao-international-bathymetric-chart-of-the-arctic-ocean-class-for-python-and-scipy ( https://github.com/gauteh/ibcao_py ) Cheers, Gaute Excerpts from Bill Wang's message of October 20, 2014 9:48: > Hi all! I've tried to plot some (sea ice thickness, snow freeboard > etc.) netcdf-data on Antarctic waters but there seems to be something > funny here since the plot is kind of cut in half or something. from > Scientific.IO.NetCDF import NetCDFFile # Also numpy as np, Basemap > etc, matplotlib as plt. F = NetCDFFile('data.nc','r')lat = > F.variables['nav_lat'][:,0]lon = F.variables['nev_lon'][0,:]data = > np.ma.masked_where(np.isnan(F.variables['iice_hid'][0,2,:,:]), > F.variables['iice_hid'][0,2,:,:])m = > Basemap(projection='spaeqd',boundinglat=-50,lon_0=180,resolution='l')lons, > lats = np.meshgrid(lon,lat)fig = > plt.figure()m.pcolormesh(lons,lats,data,latlon=True,vmin=0,vmax=2.3)m2.drawcoastlines()plt.show() > > > Unfortunately I can't provide any data, but the dimensions are:x=1442; > y=1021; icethi(=layers)=5; time_counter=1Longitudes are like (y,x), in > degrees_east, min -180 and max 180Latitudes are (y,x), in > degrees_north, min -77, max 89Data (the one to draw) is > (time_counter,icethi,y,x). Without meshgrid there is a RuntimeError: > Buffer lengths not the same. Also I've tried many other projections > like spstere, laea,splaea... With addcyclic the result looks exactly > the same so that can't be the problem either. The netcdf file doesn't > contain any more information about coordinate systems or projection, > just that lon and lat model is in "Default grid" what ever that means. > I would be very thankful if anyone can help me or give me a glue, from > where to look for a solution Cheers, Bill! -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] unable to run simpletest.py
Here is a more detailed crash report in addition to the one from the command line: Application Specific Information: Assertion failed: (0), function query, file AbstractSTRtree.cpp, line 285. Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x7fff93f2e866 __pthread_kill + 10 1 libsystem_pthread.dylib 0x7fff9a44035c pthread_kill + 92 2 libsystem_c.dylib 0x7fff935bfb1a abort + 125 3 libsystem_c.dylib 0x7fff935899bf __assert_rtn + 321 4 libgeos-3.4.2.dylib 0x000105df3e6b geos::index::strtree::AbstractSTRtree::query(void const*, geos::index::strtree::AbstractNode const*, std::__1::vector >*) + 363 5 libgeos-3.4.2.dylib 0x000105e09c4d geos::noding::MCIndexNoder::intersectChains() + 173 6 libgeos-3.4.2.dylib 0x000105e10514 geos::operation::buffer::BufferBuilder::computeNodedEdges(std::__1::vector >&, geos::geom::PrecisionModel const*) + 50 7 libgeos-3.4.2.dylib 0x000105e10028 geos::operation::buffer::BufferBuilder::buffer(geos::geom::Geometry const*, double) + 170 8 libgeos-3.4.2.dylib 0x000105e11e84 geos::operation::buffer::BufferOp::bufferOriginalPrecision() + 178 9 libgeos-3.4.2.dylib 0x000105e11d94 geos::operation::buffer::BufferOp::computeGeometry() + 14 10 libgeos-3.4.2.dylib 0x000105e11d35 geos::operation::buffer::BufferOp::bufferOp(geos::geom::Geometry const*, double, int, int) + 79 11 libgeos_c.1.dylib 0x000105ba8f9f GEOSBuffer_r + 42 12 _geoslib.so 0x0001056ee0ac __pyx_pw_8_geoslib_12BaseGeometry_11fix + 28 (_geoslib.c:1990) 13 org.python.python 0x0001000e5496 PyEval_EvalFrameEx + 31398 14 org.python.python 0x0001000e665d PyEval_EvalCodeEx + 2349 15 org.python.python 0x0001000e51f7 PyEval_EvalFrameEx + 30727 16 org.python.python 0x0001000e665d PyEval_EvalCodeEx + 2349 17 org.python.python 0x00010003f76a function_call + 186 18 org.python.python 0x0001da08 PyObject_Call + 104 19 org.python.python 0x00010002941c method_call + 140 20 org.python.python 0x0001da08 PyObject_Call + 104 21 org.python.python 0x000100078651 slot_tp_init + 81 22 org.python.python 0x0001000736c4 type_call + 212 23 org.python.python 0x0001da08 PyObject_Call + 104 24 org.python.python 0x0001000e1c3f PyEval_EvalFrameEx + 16975 25 org.python.python 0x0001000e665d PyEval_EvalCodeEx + 2349 26 org.python.python 0x0001000e671f PyEval_EvalCode + 63 27 org.python.python 0x000100110b2e PyRun_FileExFlags + 206 28 org.python.python 0x000100110edd PyRun_SimpleFileExFlags + 717 29 org.python.python 0x00010012856e Py_Main + 3262 30 org.python.python 0x00010e32 0x1 + 3634 31 org.python.python 0x00010c84 0x1 + 3204 On Fri, Oct 17, 2014 at 3:57 AM, Tommy Carstensen wrote: > To matplotlib-users, > > I ran the installation guide here on Mac OS: > http://matplotlib.org/basemap/users/installing.html > > Except I did brew install geos and subsequently did: > export DYLD_LIBRARY_PATH=/Users/tc9/homebrew/lib > export GEOS_LIBRARY_PATH=/Users/tc9/homebrew/Cellar/geos/3.4.2 > export GEOS_DIR=/Users/tc9/homebrew/Cellar/geos/3.4.2 > > And instead of python setup.py install I did: > /usr/local/bin/python3 setup.py install --user > > I got this warning: > /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py:260: > UserWarning: Unknown distribution option: 'namespace_packages' > warnings.warn(msg) > > When I try to run simpletest.py in the folder examples with > /usr/local/bin/python3 I get this error: > Assertion failed: (0), function query, file AbstractSTRtree.cpp, line 285. > Abort trap: 6 > > What am I doing wrong? > > Thanks, > Tommy -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] adding legends
Does anyone know, how they were able to add the legend titles "damped" and "oscillatory" to this plot: http://matplotlib.org/examples/pylab_examples/legend_demo.html Can anyone point me to a good tutorial on matplotlib legends? This one is somewhat limited: http://matplotlib.org/users/legend_guide.html Thanks. -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] avoid duplicate legends
How does one avoid duplicate legends? www.tommycarstensen.com/python2_matplotlib_basemap_merc_bluemarble_hresolution.jpg Can I make the legend size smaller than the marker size? -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] adding legends
Indeed, the legends showing in that figure should be 'Model length', 'Data length' and 'Total message length', which were the labels given to each plot command. Maybe there was a mismatch between code and plot there. 2014-10-20 11:59 GMT-02:00 Tommy Carstensen : > Does anyone know, how they were able to add the legend titles "damped" > and "oscillatory" to this plot: > http://matplotlib.org/examples/pylab_examples/legend_demo.html > > Can anyone point me to a good tutorial on matplotlib legends? This one > is somewhat limited: > http://matplotlib.org/users/legend_guide.html > > Thanks. > > > -- > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] adding legends
Le lundi 20 octobre 2014 à 06:59 -0700, Tommy Carstensen a écrit : > Does anyone know, how they were able to add the legend titles "damped" > and "oscillatory" to this plot: > http://matplotlib.org/examples/pylab_examples/legend_demo.html Hi, it seems to me that you are looking to some deprecated example, not even listed in the page : http://matplotlib.org/examples/pylab_examples/ It has been rewritten as http://matplotlib.org/examples/pylab_examples/legend_demo2.html http://matplotlib.org/examples/pylab_examples/legend_demo3.html http://matplotlib.org/examples/pylab_examples/legend_demo4.html > Can anyone point me to a good tutorial on matplotlib legends? This one > is somewhat limited: > http://matplotlib.org/users/legend_guide.html I find it pretty concise and understandable... Have you seen the list of examples involving legend at the bottom of that page? -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] avoid duplicate legends
For your first question: Use the legend "numpoints" keyword. I think if you set it to 1, it should solve that problem. For your second question, I'm not sure, but I'll bet if you poke around in the Legend object returned by the function, you'll find something. On Mon, Oct 20, 2014 at 8:04 AM, Tommy Carstensen wrote: > How does one avoid duplicate legends? > www.tommycarstensen.com/python2_matplotlib_basemap_merc_bluemarble_hresolution.jpg > > Can I make the legend size smaller than the marker size? > > -- > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] avoid duplicate legends
Legends entries are blindly constructed. Each plotting call that has a legend keyword argument will produce a legend entry if you are automatically building the legend. You can pass a label value of "__nolabel__" to prevent an entry if you know you are about to do something that would duplicate the entries. Another approach is to manually collect unique artists and manually build the legend (I think there is an example of that in the gallary). As for configuring the legend, there are a bunch of parameters that can be set for sizing the font. I think the sizing of the marker is determined by their size in the plot, though. Cheers! Ben Root On Mon, Oct 20, 2014 at 10:46 AM, Hearne, Mike wrote: > For your first question: Use the legend "numpoints" keyword. I think > if you set it to 1, it should solve that problem. > > For your second question, I'm not sure, but I'll bet if you poke > around in the Legend object returned by the function, you'll find > something. > > On Mon, Oct 20, 2014 at 8:04 AM, Tommy Carstensen > wrote: > > How does one avoid duplicate legends? > > > www.tommycarstensen.com/python2_matplotlib_basemap_merc_bluemarble_hresolution.jpg > > > > Can I make the legend size smaller than the marker size? > > > > > -- > > Comprehensive Server Monitoring with Site24x7. > > Monitor 10 servers for $9/Month. > > Get alerted through email, SMS, voice calls or mobile push notifications. > > Take corrective actions from your mobile device. > > http://p.sf.net/sfu/Zoho > > ___ > > Matplotlib-users mailing list > > Matplotlib-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > -- > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users