Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 844088e

Browse files
committed
more updates to docs
svn path=/trunk/matplotlib/; revision=6198
1 parent aa8b353 commit 844088e

10 files changed

Lines changed: 150 additions & 3 deletions

File tree

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
# (source start file, target name, title, author, document class [howto/manual]).
153153

154154
latex_documents = [
155-
('index', 'Matplotlib.tex', 'Matplotlib', 'Darren Dale, Michael Droettboom, Eric Firing, John Hunter', 'manual'),
155+
('contents', 'Matplotlib.tex', 'Matplotlib', 'Darren Dale, Michael Droettboom, Eric Firing, John Hunter', 'manual'),
156156
]
157157

158158

doc/pyplots/README

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,12 @@ generate a new figure.
44
tex_demo.py and tex_unicode_demo.py:
55
latex
66
dvipng
7+
8+
9+
plotmap.py:
10+
basemap toolkit
11+
12+
some data files - do a svn co
13+
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/htdocs/screenshots/data/
14+
to get the data and then set the datadir variable in the
15+
plotmap.py file to point to this data direcotry

doc/pyplots/make.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ def figs():
3232
plt.close('all') # we need to clear between runs
3333
mplshell.magic_run(basename)
3434
for imagefile, dpi in imagefiles.iteritems():
35+
# todo: this will get called even if the run script
36+
# fails and exits, thus creating a stub pdf and png
37+
# iles preventing them from getting built successfully
38+
# later
3539
plt.savefig(imagefile, dpi=dpi)
3640
print 'all figures made'
3741

doc/pyplots/plotmap.hires.png

1010 KB
Loading

doc/pyplots/plotmap.pdf

1.81 MB
Binary file not shown.

doc/pyplots/plotmap.png

366 KB
Loading

doc/pyplots/plotmap.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# make plot of etopo bathymetry/topography data on
2+
# lambert conformal conic map projection, drawing coastlines, state and
3+
# country boundaries, and parallels/meridians.
4+
5+
# the data is interpolated to the native projection grid.
6+
import os
7+
from mpl_toolkits.basemap import Basemap, shiftgrid
8+
from pylab import title, colorbar, show, axes, cm, load, arange, figure, \
9+
text
10+
11+
# read in topo data (on a regular lat/lon grid)
12+
# longitudes go from 20 to 380.
13+
# you can get this data from matplolib svn matplotlib/htdocs/screenshots/data/
14+
datadir = '/home/jdhunter/python/svn/matplotlib/htdocs/screenshots/data/'
15+
if not os.path.exists(datadir):
16+
raise SystemExit('You need to download the data with svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/htdocs/screenshots/data/" and set the datadir variable in %s'%__file__)
17+
18+
topoin = load(os.path.join(datadir, 'etopo20data.gz'))
19+
lons = load(os.path.join(datadir, 'etopo20lons.gz'))
20+
lats = load(os.path.join(datadir, 'etopo20lats.gz'))
21+
# shift data so lons go from -180 to 180 instead of 20 to 380.
22+
topoin,lons = shiftgrid(180.,topoin,lons,start=False)
23+
24+
# setup of basemap ('lcc' = lambert conformal conic).
25+
# use major and minor sphere radii from WGS84 ellipsoid.
26+
m = Basemap(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
27+
rsphere=(6378137.00,6356752.3142),\
28+
resolution='l',area_thresh=1000.,projection='lcc',\
29+
lat_1=50.,lon_0=-107.)
30+
# transform to nx x ny regularly spaced native projection grid
31+
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
32+
topodat,x,y = m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True)
33+
# create the figure.
34+
fig=figure(figsize=(8,8))
35+
# add an axes, leaving room for colorbar on the right.
36+
ax = fig.add_axes([0.1,0.1,0.7,0.7])
37+
# plot image over map with imshow.
38+
im = m.imshow(topodat,cm.jet)
39+
# setup colorbar axes instance.
40+
# for matplotlib 0.91 and earlier, could do l,b,w,h = ax.get_position()
41+
# for post 0.91, pos = ax.get_position(); l,b,w,h = pos.bounds
42+
# this works for both.
43+
pos = ax.get_position()
44+
l, b, w, h = getattr(pos, 'bounds', pos)
45+
cax = axes([l+w+0.075, b, 0.05, h])
46+
colorbar(cax=cax) # draw colorbar
47+
axes(ax) # make the original axes current again
48+
# plot blue dot on boulder, colorado and label it as such.
49+
xpt,ypt = m(-104.237,40.125)
50+
m.plot([xpt],[ypt],'bo')
51+
text(xpt+100000,ypt+100000,'Boulder')
52+
# draw coastlines and political boundaries.
53+
m.drawcoastlines()
54+
m.drawcountries()
55+
m.drawstates()
56+
# draw parallels and meridians.
57+
# label on left, right and bottom of map.
58+
parallels = arange(0.,80,20.)
59+
m.drawparallels(parallels,labels=[1,1,0,1])
60+
meridians = arange(10.,360.,30.)
61+
m.drawmeridians(meridians,labels=[1,1,0,1])
62+
# set title.
63+
title('ETOPO Topography - Lambert Conformal Conic')
64+
show()

doc/users/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ User's Guide
2020
index_text.rst
2121
artists.rst
2222
event_handling.rst
23+
toolkits.rst
2324
screenshots.rst
2425

2526

doc/users/screenshots.rst

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ user interface you are using, allowing you to write cross GUI figures
126126
and widgets. See matplotlib.widgets and the widget `examples
127127
<examples/widgets>`
128128

129-
.. plot:: ../mpl_examples/widgets/sliders.py
129+
.. plot:: ../mpl_examples/widgets/slider_demo.py
130130

131131

132132
.. _screenshots_fill_demo:
@@ -150,7 +150,36 @@ You can plot date data with major and minor ticks and custom tick
150150
formatters for both the major and minor ticks; see matplotlib.ticker
151151
and matplotlib.dates for details and usage.
152152

153-
.. plot:: ../mpl_examples/api/date_demo.py
153+
todoplot:: ../mpl_examples/api/date_demo.py
154154

155+
.. _screenshots_jdh_demo:
156+
157+
Financial charts
158+
================
159+
160+
You can make much more sophisticated financial plots. This example
161+
emulates one of the `ChartDirector`<http://www.advsofteng.com/gallery_finance.html>
162+
financial plots. Some of the data in the plot, are real financial
163+
data, some are random traces that I used since the goal was to
164+
illustrate plotting techniques, not market analysis!
165+
166+
167+
todoplot:: ../mpl_examples/pylab_examples/finance_work2.py
168+
169+
170+
.. _screenshots_basemap_demo:
171+
172+
Basemap demo
173+
============
174+
175+
Jeff Whitaker provided this example showing how to efficiently plot a
176+
collection of lines over a colormap image using the
177+
:ref:`toolkit_basemap` . Many map projections are handled via the
178+
proj4 library: cylindrical equidistant, mercator, lambert conformal
179+
conic, lambert azimuthal equal area, albers equal area conic and
180+
stereographic. See the `tutorial
181+
<http://www.scipy.org/wikis/topical_software/Maps>` entry on the wiki.
182+
183+
.. plot:: plotmap.py
155184

156185

doc/users/toolkits.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.. _toolkits:
2+
3+
*******************
4+
matplotlib toolkits
5+
*******************
6+
7+
Toolkits are collections of application-specific functions that extend matplotlib.
8+
9+
.. _toolkit_basemap:
10+
11+
Basemap
12+
=======
13+
14+
Plots data on map projections, with continental and political
15+
boundaries, `see <http://matplotlib.sf.net/basemap/doc/html>`
16+
17+
.. _toolkit_gtk:
18+
19+
GTK Tools
20+
=========
21+
mpl_toolkits.gtktools provides some utilities for working with GTK. This toolkit ships with matplotlib, but requires `pygtk <http://www.pygtk.org/>`.
22+
23+
.. _toolkit_excel:
24+
25+
Excel Tools
26+
===========
27+
28+
mpl_toolkits.exceltools provides some utilities for working with Excel. This toolkit ships with matplotlib, but requires `pyExcelerator <http://sourceforge.net/projects/pyexcelerator>`
29+
30+
.. _toolkit_natgrid:
31+
32+
Natrgrid
33+
========
34+
35+
mpl_toolkits.natgrid is an interface to natgrid C library for gridding
36+
irregularly spaced data. This requires a separate installation of the
37+
natgrid toolkit from the sourceforge `download
38+
<http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=142792>`
39+
page.
40+

0 commit comments

Comments
 (0)