Commit 1350f1cd authored by Sandro Tosi's avatar Sandro Tosi

New upstream version 1.2.0+dfsg

parent 3778c573
...@@ -67,3 +67,5 @@ doc/examples ...@@ -67,3 +67,5 @@ doc/examples
doc/_templates/gallery.html doc/_templates/gallery.html
doc/users/installing.rst doc/users/installing.rst
doc/_static/matplotlibrc doc/_static/matplotlibrc
.DS_Store
...@@ -12,7 +12,7 @@ env: ...@@ -12,7 +12,7 @@ env:
addons: addons:
apt: apt:
packages: packages:
- libgeos-3.3.8 - libgeos-3.4.2
# matplotlib requirements # matplotlib requirements
- libpng12-dev - libpng12-dev
- libfreetype6-dev - libfreetype6-dev
......
version 1.2.0
-------------
* Mostly compatibility bugfixes
version 1.1.0 (git tag v1.1.0rel) version 1.1.0 (git tag v1.1.0rel)
-------------------------------- --------------------------------
* Updated packaged data to use GSHHG v2.3.6 (PR #311 & #320) * Updated packaged data to use GSHHG v2.3.6 (PR #311 & #320)
......
#Basemap # Basemap
Plot on map projections (with coastlines and political boundaries) Plot on map projections (with coastlines and political boundaries)
using matplotlib. using matplotlib.
##Requirements ## Requirements
* Python 2.6 (or higher) * Python 2.6 (or higher)
...@@ -23,7 +23,7 @@ sure the corresponding "python-dev" package is also installed. Otherwise, you ...@@ -23,7 +23,7 @@ sure the corresponding "python-dev" package is also installed. Otherwise, you
may not have the python header (Python.h), which is required to build python may not have the python header (Python.h), which is required to build python
C extensions. C extensions.
###Optional ### Optional
* [OWSLib](https://github.com/geopython/OWSLib) (optional) It is needed * [OWSLib](https://github.com/geopython/OWSLib) (optional) It is needed
for the BaseMap.wmsimage function. for the BaseMap.wmsimage function.
...@@ -32,7 +32,7 @@ for the BaseMap.wmsimage function. ...@@ -32,7 +32,7 @@ for the BaseMap.wmsimage function.
needed for Basemap warpimage, bluemarble, shadedrelief, and etop methods. needed for Basemap warpimage, bluemarble, shadedrelief, and etop methods.
PIL should work on Python 2.x. Pillow is a maintained fork of PIL. PIL should work on Python 2.x. Pillow is a maintained fork of PIL.
##Copyright ## Copyright
source code for the GEOS library is source code for the GEOS library is
included in the 'geos-3.3.3' directory under the terms given in included in the 'geos-3.3.3' directory under the terms given in
...@@ -59,7 +59,7 @@ USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR ...@@ -59,7 +59,7 @@ USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
##Documentation ## Documentation
see http://matplotlib.github.com/basemap/ see http://matplotlib.github.com/basemap/
...@@ -68,7 +68,7 @@ see scripts in 'examples' directory for example usage. ...@@ -68,7 +68,7 @@ see scripts in 'examples' directory for example usage.
read the FAQ and/or email the matplotlib-users mailing list if read the FAQ and/or email the matplotlib-users mailing list if
you have problems or questions. you have problems or questions.
##Install ## Install
0. Install pre-requisite python modules numpy and matplotlib. 0. Install pre-requisite python modules numpy and matplotlib.
...@@ -100,10 +100,10 @@ prompt. ...@@ -100,10 +100,10 @@ prompt.
To run all the examples (except those that have extra dependencies To run all the examples (except those that have extra dependencies
or require an internet connection), execute 'python run_all.py'. or require an internet connection), execute 'python run_all.py'.
##Contact ## Contact
Ben Root <ben.v.root@gmail.com> Ben Root <ben.v.root@gmail.com>
##Thanks ## Thanks
Special thanks to John Hunter, Andrew Straw, Eric Firing, Rob Hetland, Scott Sinclair, Ivan Lima, Erik Andersen, Michael Hearne, Jesper Larsen, Ryan May, David Huard, Mauro Cavalcanti, Jonas Bluethgen, Chris Murphy, Pierre Gerard-Marchant, Christoph Gohlke, Eric Bruning, Stephane Raynaud, Tom Loredo, Patrick Marsh, Phil Elson, and Henry Hammond for valuable contributions. Special thanks to John Hunter, Andrew Straw, Eric Firing, Rob Hetland, Scott Sinclair, Ivan Lima, Erik Andersen, Michael Hearne, Jesper Larsen, Ryan May, David Huard, Mauro Cavalcanti, Jonas Bluethgen, Chris Murphy, Pierre Gerard-Marchant, Christoph Gohlke, Eric Bruning, Stephane Raynaud, Tom Loredo, Patrick Marsh, Phil Elson, and Henry Hammond for valuable contributions.
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
# setup north polar stereographic basemap. # setup south polar stereographic basemap.
# The longitude lon_0 is at 6-o'clock, and the # The longitude lon_0 is at 6-o'clock, and the
# latitude circle boundinglat is tangent to the edge # latitude circle boundinglat is tangent to the edge
# of the map at lon_0. Default value of lat_ts # of the map at lon_0. Default value of lat_ts
......
...@@ -10,23 +10,24 @@ Dependencies ...@@ -10,23 +10,24 @@ Dependencies
**Requirements** **Requirements**
These are external packages which you will need to install before These are external packages which you will need to install before
installing basemap. installing Basemap.
matplotlib 1.0.0 (or later, `download <http://sf.net/projects/matplotlib/>`__) Matplotlib 1.0.0 (or later, `download <https://matplotlib.org/users/installing.html>`__)
Python 2.4 (or later, including Python 3) Python 2.6 (or later, including Python 3) (`download <http://www.python.org/download/>`__)
matplotlib requires python 2.4 or later (`download <http://www.python.org/download/>`__) Matplotlib 2.2 LTS requires Python 2.7 or later
Matplotlib 3.0 requires Python 3.5 or later
numpy 1.2.1 (or later) NumPy 1.2.1 (or later)
array support for python (`download <http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103>`__) Array support for Python (`download <http://www.numpy.org/>`__)
`PROJ4 <https://trac.osgeo.org/proj/>`__ Cartographic Projections Library. `PROJ4 <https://trac.osgeo.org/proj/>`__ Cartographic Projections Library.
**Required library that ships with basemap** **Required library that ships with Basemap**
`GEOS <http://trac.osgeo.org/geos/>`__ (Geometry Engine - Open Source) library 3.1.1 or later. `GEOS <http://trac.osgeo.org/geos/>`__ (Geometry Engine - Open Source) library 3.1.1 or later.
Source code is included in the geos-3.3.3 directory. Source code is included in the geos-3.3.3 directory.
When building from source, must be built and installed separately When building from source, must be built and installed separately
from basemap (see build instructions below). from basemap (see build instructions below).
Included in Windows binary installers. Included in Windows binary installers.
...@@ -40,8 +41,8 @@ Pillow ...@@ -40,8 +41,8 @@ Pillow
Installation Installation
============ ============
Download either Windows binary installers or source tarballs Download either Windows binary installers or source tarballs
`here <https://github.com/matplotlib/basemap/releases/>`__. `here <https://github.com/matplotlib/basemap/releases/>`__.
To install from the source, follow these steps: To install from the source, follow these steps:
...@@ -52,7 +53,7 @@ To install from the source, follow these steps: ...@@ -52,7 +53,7 @@ To install from the source, follow these steps:
and cd to the basemap-X.Y.Z directory. and cd to the basemap-X.Y.Z directory.
* Install the GEOS library. If you already have it on your * Install the GEOS library. If you already have it on your
system, just set the environment variable GEOS_DIR to point to the location system, just set the environment variable GEOS_DIR to point to the location
of libgeos_c and geos_c.h (if libgeos_c is in /usr/local/lib and of libgeos_c and geos_c.h (if libgeos_c is in /usr/local/lib and
geos_c.h is in /usr/local/include, set GEOS_DIR to /usr/local). geos_c.h is in /usr/local/include, set GEOS_DIR to /usr/local).
Then go to next step. If you don't have it, you can build it from Then go to next step. If you don't have it, you can build it from
...@@ -62,12 +63,12 @@ To install from the source, follow these steps: ...@@ -62,12 +63,12 @@ To install from the source, follow these steps:
export GEOS_DIR=<where you want the libs and headers to go> export GEOS_DIR=<where you want the libs and headers to go>
# A reasonable choice on a Unix-like system is /usr/local, or # A reasonable choice on a Unix-like system is /usr/local, or
# if you don't have permission to write there, your home directory. # if you don't have permission to write there, your home directory.
./configure --prefix=$GEOS_DIR ./configure --prefix=$GEOS_DIR
make; make install make; make install
* cd back to the top level basemap directory (basemap-X.Y.Z) and * cd back to the top level basemap directory (basemap-X.Y.Z) and
run the usual ``python setup.py install``. Check your installation run the usual ``python setup.py install``. Check your installation
by running ``from mpl_toolkits.basemap import Basemap`` at the python by running ``from mpl_toolkits.basemap import Basemap`` at the Python
prompt. prompt.
* To test, cd to the examples directory and run ``python simpletest.py``. * To test, cd to the examples directory and run ``python simpletest.py``.
......
from __future__ import (absolute_import, division, print_function)
from __future__ import unicode_literals from __future__ import unicode_literals
""" """
AllSkyMap is a subclass of Basemap, specialized for handling common plotting AllSkyMap is a subclass of Basemap, specialized for handling common plotting
......
from __future__ import (absolute_import, division, print_function)
""" """
Example of astronomical use of AllSkyMap class in allskymap.py module Example of astronomical use of AllSkyMap class in allskymap.py module
......
from __future__ import (absolute_import, division, print_function)
# example using matplotlib.animation to create a movie # example using matplotlib.animation to create a movie
# reads data over http - needs an active internet connection. # reads data over http - needs an active internet connection.
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
""" """
This example shows how to plot data on rectangular 2D grids This example shows how to plot data on rectangular 2D grids
(grids that are not rectlinear in geographic or native map projection (grids that are not rectlinear in geographic or native map projection
...@@ -56,7 +58,7 @@ m.drawcoastlines() ...@@ -56,7 +58,7 @@ m.drawcoastlines()
m.fillcontinents(color='white') m.fillcontinents(color='white')
x, y = m(tlon,tlat) x, y = m(tlon,tlat)
im = m.pcolor(x,y,ma.masked_array(np.zeros(temp.shape,'f'), temp.mask), im = m.pcolormesh(x,y,ma.masked_array(np.zeros(temp.shape,'f'), temp.mask),
shading='faceted', antialiased=True, cmap=plt.cm.cool, shading='faceted', antialiased=True, cmap=plt.cm.cool,
vmin=0, vmax=0) vmin=0, vmax=0)
# disclaimer: these are not really the grid cells because of the # disclaimer: these are not really the grid cells because of the
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
def draw_map_background(m, ax): def draw_map_background(m, ax):
ax.set_axis_bgcolor('#729FCF') ax.set_facecolor('#729FCF')
m.fillcontinents(color='#FAFAFA', ax=ax, zorder=0) m.fillcontinents(color='#FAFAFA', ax=ax, zorder=0)
m.drawcounties(ax=ax) m.drawcounties(ax=ax)
m.drawstates(ax=ax) m.drawstates(ax=ax)
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
......
from __future__ import (absolute_import, division, print_function)
from __future__ import unicode_literals from __future__ import unicode_literals
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import numpy as np import numpy as np
......
from __future__ import (absolute_import, division, print_function)
import numpy as np import numpy as np
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
#!/usr/bin/env python #!/usr/bin/env python
""" """
An example of how to use wx or wxagg in an application with the Basemap module An example of how to use wx or wxagg in an application with the Basemap module
......
from __future__ import print_function from __future__ import (absolute_import, division, print_function)
from __future__ import unicode_literals from __future__ import unicode_literals
# this example reads today's numerical weather forecasts # this example reads today's numerical weather forecasts
# from the NOAA OpenDAP servers and makes a multi-panel plot. # from the NOAA OpenDAP servers and makes a multi-panel plot.
......
from __future__ import print_function from __future__ import (absolute_import, division, print_function)
from __future__ import unicode_literals from __future__ import unicode_literals
# this example reads today's numerical weather forecasts # this example reads today's numerical weather forecasts
# from the NOAA OpenDAP servers and makes a multi-panel plot. # from the NOAA OpenDAP servers and makes a multi-panel plot.
......
from __future__ import print_function from __future__ import (absolute_import, division, print_function)
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap as Basemap from mpl_toolkits.basemap import Basemap as Basemap
from matplotlib.colors import rgb2hex from matplotlib.colors import rgb2hex, Normalize
from matplotlib.patches import Polygon from matplotlib.patches import Polygon
from matplotlib.colorbar import ColorbarBase
fig, ax = plt.subplots()
# Lambert Conformal map of lower 48 states. # Lambert Conformal map of lower 48 states.
m = Basemap(llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49, m = Basemap(llcrnrlon=-119,llcrnrlat=20,urcrnrlon=-64,urcrnrlat=49,
projection='lcc',lat_1=33,lat_2=45,lon_0=-95) projection='lcc',lat_1=33,lat_2=45,lon_0=-95)
# draw state boundaries.
# data from U.S Census Bureau # Mercator projection, for Alaska and Hawaii
# http://www.census.gov/geo/www/cob/st2000.html m_ = Basemap(llcrnrlon=-190,llcrnrlat=20,urcrnrlon=-143,urcrnrlat=46,
shp_info = m.readshapefile('st99_d00','states',drawbounds=True) projection='merc',lat_ts=20) # do not change these numbers
# population density by state from
# http://en.wikipedia.org/wiki/List_of_U.S._states_by_population_density #%% --------- draw state boundaries ----------------------------------------
## data from U.S Census Bureau
## http://www.census.gov/geo/www/cob/st2000.html
shp_info = m.readshapefile('st99_d00','states',drawbounds=True,
linewidth=0.45,color='gray')
shp_info_ = m_.readshapefile('st99_d00','states',drawbounds=False)
## population density by state from
## http://en.wikipedia.org/wiki/List_of_U.S._states_by_population_density
popdensity = { popdensity = {
'New Jersey': 438.00, 'New Jersey': 438.00,
'Rhode Island': 387.35, 'Rhode Island': 387.35,
...@@ -65,13 +77,13 @@ popdensity = { ...@@ -65,13 +77,13 @@ popdensity = {
'Montana': 2.39, 'Montana': 2.39,
'Wyoming': 1.96, 'Wyoming': 1.96,
'Alaska': 0.42} 'Alaska': 0.42}
print(shp_info)
# choose a color for each state based on population density. #%% -------- choose a color for each state based on population density. -------
colors={} colors={}
statenames=[] statenames=[]
cmap = plt.cm.hot # use 'hot' colormap cmap = plt.cm.hot_r # use 'reversed hot' colormap
vmin = 0; vmax = 450 # set range. vmin = 0; vmax = 450 # set range.
print(m.states_info[0].keys()) norm = Normalize(vmin=vmin, vmax=vmax)
for shapedict in m.states_info: for shapedict in m.states_info:
statename = shapedict['NAME'] statename = shapedict['NAME']
# skip DC and Puerto Rico. # skip DC and Puerto Rico.
...@@ -80,18 +92,51 @@ for shapedict in m.states_info: ...@@ -80,18 +92,51 @@ for shapedict in m.states_info:
# calling colormap with value between 0 and 1 returns # calling colormap with value between 0 and 1 returns
# rgba value. Invert color range (hot colors are high # rgba value. Invert color range (hot colors are high
# population), take sqrt root to spread out colors more. # population), take sqrt root to spread out colors more.
colors[statename] = cmap(1.-np.sqrt((pop-vmin)/(vmax-vmin)))[:3] colors[statename] = cmap(np.sqrt((pop-vmin)/(vmax-vmin)))[:3]
statenames.append(statename) statenames.append(statename)
# cycle through state names, color each one.
ax = plt.gca() # get current axes instance #%% --------- cycle through state names, color each one. --------------------
for nshape,seg in enumerate(m.states): for nshape,seg in enumerate(m.states):
# skip DC and Puerto Rico. # skip DC and Puerto Rico.
if statenames[nshape] not in ['District of Columbia','Puerto Rico']: if statenames[nshape] not in ['Puerto Rico', 'District of Columbia']:
color = rgb2hex(colors[statenames[nshape]]) color = rgb2hex(colors[statenames[nshape]])
poly = Polygon(seg,facecolor=color,edgecolor=color) poly = Polygon(seg,facecolor=color,edgecolor=color)
ax.add_patch(poly) ax.add_patch(poly)
# draw meridians and parallels.
m.drawparallels(np.arange(25,65,20),labels=[1,0,0,0]) AREA_1 = 0.005 # exclude small Hawaiian islands that are smaller than AREA_1
m.drawmeridians(np.arange(-120,-40,20),labels=[0,0,0,1]) AREA_2 = AREA_1 * 30.0 # exclude Alaskan islands that are smaller than AREA_2
plt.title('Filling State Polygons by Population Density') AK_SCALE = 0.19 # scale down Alaska to show as a map inset
HI_OFFSET_X = -1900000 # X coordinate offset amount to move Hawaii "beneath" Texas
HI_OFFSET_Y = 250000 # similar to above: Y offset for Hawaii
AK_OFFSET_X = -250000 # X offset for Alaska (These four values are obtained
AK_OFFSET_Y = -750000 # via manual trial and error, thus changing them is not recommended.)
for nshape, shapedict in enumerate(m_.states_info): # plot Alaska and Hawaii as map insets
if shapedict['NAME'] in ['Alaska', 'Hawaii']:
seg = m_.states[int(shapedict['SHAPENUM'] - 1)]
if shapedict['NAME'] == 'Hawaii' and float(shapedict['AREA']) > AREA_1:
seg = [(x + HI_OFFSET_X, y + HI_OFFSET_Y) for x, y in seg]
color = rgb2hex(colors[statenames[nshape]])
elif shapedict['NAME'] == 'Alaska' and float(shapedict['AREA']) > AREA_2:
seg = [(x*AK_SCALE + AK_OFFSET_X, y*AK_SCALE + AK_OFFSET_Y)\
for x, y in seg]
color = rgb2hex(colors[statenames[nshape]])
poly = Polygon(seg, facecolor=color, edgecolor='gray', linewidth=.45)
ax.add_patch(poly)
ax.set_title('United states population density by state')
#%% --------- Plot bounding boxes for Alaska and Hawaii insets --------------
light_gray = [0.8]*3 # define light gray color RGB
x1,y1 = m_([-190,-183,-180,-180,-175,-171,-171],[29,29,26,26,26,22,20])
x2,y2 = m_([-180,-180,-177],[26,23,20]) # these numbers are fine-tuned manually
m_.plot(x1,y1,color=light_gray,linewidth=0.8) # do not change them drastically
m_.plot(x2,y2,color=light_gray,linewidth=0.8)
#%% --------- Show color bar ---------------------------------------
ax_c = fig.add_axes([0.9, 0.1, 0.03, 0.8])
cb = ColorbarBase(ax_c,cmap=cmap,norm=norm,orientation='vertical',
label=r'[population per $\mathregular{km^2}$]')
plt.show() plt.show()
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
"""geos_demo_2.py """geos_demo_2.py
This script shows how to plot data onto the Geostationary Satellite projection This script shows how to plot data onto the Geostationary Satellite projection
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
...@@ -6,7 +8,7 @@ fig = plt.figure() ...@@ -6,7 +8,7 @@ fig = plt.figure()
lon_0=57 lon_0=57
# global geos map # global geos map
m1 = Basemap(projection='geos',lon_0=lon_0,rsphere=(6378137.00,6356752.3142),resolution=None) m1 = Basemap(projection='geos',lon_0=lon_0,rsphere=(6378137.00,6356752.3142),resolution=None)
ax = fig.add_axes([0.1,0.1,0.8,0.8],axisbg='k') ax = fig.add_axes([0.1,0.1,0.8,0.8], facecolor='k')
# plot just upper right quadrant (coordinates determined from global map). # plot just upper right quadrant (coordinates determined from global map).
m = Basemap(projection='geos',lon_0=lon_0,rsphere=(6378137.00,6356752.3142),resolution='l',llcrnrx=0.,llcrnry=0.,urcrnrx=m1.urcrnrx/2.,urcrnry=m1.urcrnry/2.) m = Basemap(projection='geos',lon_0=lon_0,rsphere=(6378137.00,6356752.3142),resolution='l',llcrnrx=0.,llcrnry=0.,urcrnrx=m1.urcrnrx/2.,urcrnry=m1.urcrnry/2.)
m.drawcoastlines() m.drawcoastlines()
...@@ -22,7 +24,7 @@ fig = plt.figure() ...@@ -22,7 +24,7 @@ fig = plt.figure()
# global ortho map # global ortho map
lat_0=10. lat_0=10.
m1 = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution=None) m1 = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution=None)
ax = fig.add_axes([0.1,0.1,0.8,0.8],axisbg='k') ax = fig.add_axes([0.1,0.1,0.8,0.8], facecolor='k')
# plot just upper right quadrant (corners determined from global map). # plot just upper right quadrant (corners determined from global map).
m = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution='l',llcrnrx=0.,llcrnry=0.,urcrnrx=m1.urcrnrx/2.,urcrnry=m1.urcrnry/2.) m = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution='l',llcrnrx=0.,llcrnry=0.,urcrnrx=m1.urcrnrx/2.,urcrnry=m1.urcrnry/2.)
m.drawcoastlines() m.drawcoastlines()
......
from __future__ import (absolute_import, division, print_function)
# example showing how to plot scattered data with hexbin. # example showing how to plot scattered data with hexbin.
from numpy.random import uniform from numpy.random import uniform
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
...@@ -54,7 +56,7 @@ H, xedges, yedges = np.histogram2d(x, y, bins=bins, weights=z) ...@@ -54,7 +56,7 @@ H, xedges, yedges = np.histogram2d(x, y, bins=bins, weights=z)
H = np.ma.masked_where(mask, H/bincount) H = np.ma.masked_where(mask, H/bincount)
# set color of masked values to axes background (hexbin does this by default) # set color of masked values to axes background (hexbin does this by default)
palette = plt.cm.jet palette = plt.cm.jet
palette.set_bad(ax.get_axis_bgcolor(), 1.0) palette.set_bad(ax.get_facecolor(), 1.0)
CS = m.pcolormesh(xedges,yedges,H.T,shading='flat',cmap=palette) CS = m.pcolormesh(xedges,yedges,H.T,shading='flat',cmap=palette)
# draw coastlines, lat/lon lines. # draw coastlines, lat/lon lines.
m.drawcoastlines() m.drawcoastlines()
......
from __future__ import print_function from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
......
from __future__ import print_function from __future__ import (absolute_import, division, print_function)
""" """
draw Atlantic Hurricane Tracks for storms that reached Cat 4 or 5. draw Atlantic Hurricane Tracks for storms that reached Cat 4 or 5.
part of the track for which storm is cat 4 or 5 is shown red. part of the track for which storm is cat 4 or 5 is shown red.
......
from __future__ import (absolute_import, division, print_function)
# example showing how to use Line Integral Convolution to visualize a vector # example showing how to use Line Integral Convolution to visualize a vector
# flow field (from Hurricane Earl). Produces something akin to streamlines. # flow field (from Hurricane Earl). Produces something akin to streamlines.
# Requires vectorplot scikit (http://scikits.appspot.com/vectorplot). # Requires vectorplot scikit (http://scikits.appspot.com/vectorplot).
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
from mpl_toolkits.axes_grid1.inset_locator import inset_axes from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap, shiftgrid, maskoceans, interp from mpl_toolkits.basemap import Basemap, shiftgrid, maskoceans, interp
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
...@@ -32,7 +34,7 @@ plt.title('Near-Sided Perspective Map Centered on Lon=%s, Lat=%s, H=%g' %\ ...@@ -32,7 +34,7 @@ plt.title('Near-Sided Perspective Map Centered on Lon=%s, Lat=%s, H=%g' %\
fig = plt.figure() fig = plt.figure()
m1 = Basemap(projection='nsper',lon_0=lon_0,lat_0=lat_0,satellite_height=h,resolution=None) m1 = Basemap(projection='nsper',lon_0=lon_0,lat_0=lat_0,satellite_height=h,resolution=None)
ax = fig.add_axes([0.1,0.1,0.8,0.8],axisbg='k') ax = fig.add_axes([0.1,0.1,0.8,0.8], facecolor='k')
# plot just upper right quadrant (coordinates determined from global map). # plot just upper right quadrant (coordinates determined from global map).
m = Basemap(projection='nsper',lon_0=lon_0,lat_0=lat_0,satellite_height=h,resolution='l',llcrnrx=0.,llcrnry=0.,urcrnrx=m1.urcrnrx/2.,urcrnry=m1.urcrnry/2.) m = Basemap(projection='nsper',lon_0=lon_0,lat_0=lat_0,satellite_height=h,resolution='l',llcrnrx=0.,llcrnry=0.,urcrnrx=m1.urcrnrx/2.,urcrnry=m1.urcrnry/2.)
m.drawcoastlines() m.drawcoastlines()
......
from __future__ import (absolute_import, division, print_function)
# example demonstrating how to draw a great circle on a map. # example demonstrating how to draw a great circle on a map.
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import numpy as np import numpy as np
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
from matplotlib import rcParams from matplotlib import rcParams
from matplotlib.ticker import MultipleLocator from matplotlib.ticker import MultipleLocator
......
from __future__ import (absolute_import, division, print_function)
import numpy as np import numpy as np
import sys import sys
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
from matplotlib.mlab import prctile_rank from matplotlib.mlab import prctile_rank
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap as Basemap from mpl_toolkits.basemap import Basemap as Basemap
......