Skip to content

Commit a9530b0

Browse files
committed
fixed ticks on horiz cbar
svn path=/trunk/matplotlib/; revision=1079
1 parent bbb8a55 commit a9530b0

17 files changed

+697
-163
lines changed

CHANGELOG

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
New entries should be added at the top
22

3+
2005-03-16 Fixed tick on horiz colorbar
4+
5+
2005-03-16 Added Japanses winreg patch - JDH
6+
37
2005-03-15 backend_gtkagg.py: changed to use double buffering, this fixes
48
the problem reported Joachim Berdal Haga - "Parts of plot lagging
59
from previous frame in animation". Tested with anim.py and it makes

MANIFEST

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.matplotlibrc
22
API_CHANGES
3+
CHANGELOG
34
INSTALL
45
INTERACTIVE
56
KNOWN_BUGS
@@ -265,7 +266,6 @@ examples/break.py
265266
examples/color_demo.py
266267
examples/colours.py
267268
examples/contour_demo.py
268-
examples/contour_demo2.py
269269
examples/contour_image.py
270270
examples/contourf_demo.py
271271
examples/coords_demo.py
@@ -509,7 +509,6 @@ lib/dateutil/rrule.py
509509
lib/dateutil/tz.py
510510
lib/matplotlib/.cvsignore
511511
lib/matplotlib/__init__.py
512-
lib/matplotlib/__init__.py.~1.42.~
513512
lib/matplotlib/_contour.py
514513
lib/matplotlib/_image.py
515514
lib/matplotlib/_mathtext_data.py
@@ -519,15 +518,13 @@ lib/matplotlib/afm.py
519518
lib/matplotlib/agg.py
520519
lib/matplotlib/artist.py
521520
lib/matplotlib/axes.py
522-
lib/matplotlib/axes.py.~1.81.~
523521
lib/matplotlib/axis.py
524522
lib/matplotlib/backend_bases.py
525523
lib/matplotlib/cbook.py
526524
lib/matplotlib/cm.py
527525
lib/matplotlib/collections.py
528526
lib/matplotlib/colors.py
529527
lib/matplotlib/contour.py
530-
lib/matplotlib/contour.py.~1.4.~
531528
lib/matplotlib/dates.py
532529
lib/matplotlib/figure.py
533530
lib/matplotlib/finance.py
@@ -620,6 +617,7 @@ lib/matplotlib/numerix/_nc_imports.py
620617
lib/matplotlib/numerix/fft/__init__.py
621618
lib/matplotlib/numerix/linear_algebra/__init__.py
622619
lib/matplotlib/numerix/ma/__init__.py
620+
lib/matplotlib/numerix/mlab/.cvsignore
623621
lib/matplotlib/numerix/mlab/__init__.py
624622
lib/matplotlib/numerix/random_array/__init__.py
625623
lib/pytz/__init__.py
@@ -1202,15 +1200,18 @@ license/LICENSE_enthought.txt
12021200
license/PYTZ_LICENSE.txt
12031201
src/_backend_agg.cpp
12041202
src/_backend_agg.h
1203+
src/_backend_gdk.c
12051204
src/_contour.c
12061205
src/_gtkagg.cpp
12071206
src/_image.cpp
12081207
src/_image.h
12091208
src/_na_backend_agg.cpp
1209+
src/_na_backend_gdk.c
12101210
src/_na_contour.c
12111211
src/_na_image.cpp
12121212
src/_na_transforms.cpp
12131213
src/_nc_backend_agg.cpp
1214+
src/_nc_backend_gdk.c
12141215
src/_nc_contour.c
12151216
src/_nc_image.cpp
12161217
src/_nc_transforms.cpp

TODO

+7-1
Original file line numberDiff line numberDiff line change
@@ -663,4 +663,10 @@ ZeroDivisionError: SeparableTransformation::eval_scalars yin interval is zero; c
663663
-- add gc warning to oo agg and FAQ
664664

665665
-- DONE check why lowest contour is not labeled in contour_demo2 and why
666-
the colormap is still not applying to the contour.
666+
the colormap is still not applying to the contour.
667+
668+
-- the problem with attaching a mappable to the silent_list for
669+
contours is that it doesn't carry over when the list is sliced, eg
670+
when passing every 2nd contour and level to the labeler.
671+
672+
-- colorbar image origin with contour is broken in SVG; test PS

examples/anim.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
for i in arange(1,200):
2929
line.set_ydata(sin(x+i/10.0)) # update the data
3030
draw() # redraw the canvas
31-
31+
3232
print 'FPS:' , 200/(time.time()-tstart)

examples/backend_driver.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
'barchart_demo.py',
1515
'color_demo.py',
1616
'contour_demo.py',
17-
'contour_demo2.py',
1817
'contourf_demo.py',
1918
'csd_demo.py',
2019
'custom_ticker1.py',

examples/contour_demo.py

+63-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,76 @@
11
#!/usr/bin/env python
2+
'''
3+
Illustrate simple contour plotting, contours on an image with
4+
a colorbar for the contours, and labelled contours.
5+
6+
See also contour_image.py.
7+
'''
28
from pylab import *
39

10+
import sys
11+
fignum = 0
12+
if len(sys.argv) == 2:
13+
fignum = int(sys.argv[1])
14+
415
delta = 0.025
516
x = arange(-3.0, 3.0, delta)
617
y = arange(-2.0, 2.0, delta)
718
X, Y = meshgrid(x, y)
819
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
920
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
10-
1121
# difference of Gaussians
12-
#im = imshow(Z2-Z1, interpolation='bilinear', origin='lower', cmap=cm.bone)
13-
#axis('off')
14-
# see contour_demo2.py for a colorbar example
15-
levels, colls = contour(X, Y, Z2-Z1, levels=6,
22+
Z = 10.0 * (Z2 - Z1)
23+
24+
25+
26+
# Create a simple contour plot with labels using default colors. The
27+
# inline argument to clabel will control whether the labels are draw
28+
# over the line segments of the contour, removing the lines beneath
29+
# the label
30+
figure()
31+
levels, colls = contour(X, Y, Z)
32+
clabel(colls, inline=1, fontsize=10)
33+
title('Simplest default with labels')
34+
35+
36+
# You can force all the contours to be the same color
37+
figure()
38+
levels, colls = contour(X, Y, Z, 6,
39+
colors=('k',)
40+
)
41+
clabel(colls, levels, fontsize=9, inline=1)
42+
title('Single color')
43+
44+
45+
# And you can manually specify the colors of the contour
46+
figure()
47+
levels, colls = contour(X, Y, Z, 6,
1648
linewidths=arange(.5, 4, .5),
17-
colors=('r', 'green', 'blue', (1,1,0), '#afeeee', 0.5),
18-
origin='lower')
19-
clabel(colls,levels,fontsize=7, inline=1)
20-
#clabel(colls)
49+
colors=('r', 'green', 'blue', (1,1,0), '#afeeee', 0.5)
50+
)
51+
clabel(colls, levels, fontsize=9, inline=1)
52+
title('Crazy lines')
2153

22-
savefig('test')
23-
show()
2454

55+
# Or you can use a colormap to specify the colors; the default
56+
# colormap will be used for the contour lines
57+
figure()
58+
im = imshow(Z, interpolation='bilinear', origin='lower',
59+
cmap=cm.gray, extent=(-3,3,-2,2))
60+
levels, colls = contour(Z, arange(-1.2,1.6,0.2),
61+
origin='lower',
62+
linewidths=2,
63+
extent=(-3,3,-2,2))
64+
65+
clabel(colls, levels,
66+
inline=1,
67+
fmt='%1.1f',
68+
fontsize=10)
69+
70+
colorbar() # make a colorbar for the contour lines
71+
title('Lines with colorbar')
72+
hot() # Now change the colormap for the contour lines and colorbar
73+
74+
75+
#savefig('contour_demo')
76+
show()

examples/contour_demo2.py

-20
This file was deleted.

examples/contour_image.py

+87-43
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
contour_image.py [options]
44
55
Test combinations of contouring, filled contouring, and image plotting.
6+
For contour labelling, see contour_demo.py.
67
'''
78
from pylab import *
89
import matplotlib.numerix
@@ -16,6 +17,13 @@
1617
help="grid increment in x and y; default is 0.5")
1718
parser.add_option("-s", "--save", dest="save", default=None, metavar="FILE",
1819
help="Save to FILE; default is to not save.")
20+
parser.add_option("-e", "--extent", dest = "extent", type="int", default=0,
21+
help="""For subplots 2-4, use extent: \
22+
specify number 1 through 4 for any of 4 possibilities.""")
23+
parser.add_option("-f", "--figure", dest = "fignum", type="int", default=0,
24+
metavar="FIGNUM",
25+
help="""Plot subplot FIGNUM as a full-size plot; FIGNUM \
26+
must be in the range 1-4.""")
1927

2028
#Default delta is large because that makes it fast, and it illustrates
2129
# the correct registration between image and contours.
@@ -28,6 +36,17 @@
2836
delta = options.delta
2937
badmask = options.badmask
3038

39+
extents = ((-3,4,-4,3), (-3,4,3,-4), (4,-3,-4,3), (4,-3,3,-4))
40+
if options.extent == 0:
41+
extent = None
42+
elif options.extent <= 4 and options.extent > 0:
43+
extent = extents[options.extent - 1]
44+
print "Using extent ", extent, "to change axis mapping on subplots 2-4"
45+
else:
46+
raise ValueError("extent must be integer, 1-4")
47+
48+
fignum = options.fignum
49+
3150
x = y = arange(-3.0, 3.01, delta)
3251
X, Y = meshgrid(x, y)
3352
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
@@ -50,51 +69,76 @@
5069
else:
5170
raise ValueError("badmask must be 'none', 'edge', or 'interior'")
5271

53-
figure(1)
54-
subplot(2,2,1)
55-
levels, colls = contourf(X, Y, Zbm, 10, # [-1, -0.1, 0, 0.1],
56-
cmap=cm.jet,
57-
badmask = Badmask
58-
)
59-
# Use levels output from previous call to guarantee they are the same.
60-
levs2, colls2 = contour(X, Y, Zbm, levels,
61-
colors = 'r',
62-
badmask = Badmask,
63-
hold='on')
64-
65-
levs3, colls3 = contour(X, Y, Zbm, (0,),
66-
colors = 'g',
67-
linewidths = 2,
68-
hold='on')
69-
title('Filled contours')
70-
#colorbar()
71-
# Major reworking of the colorbar mechanism is needed for filled contours!
72-
73-
subplot(2,2,2)
74-
imshow(Z)
75-
v = axis()
76-
contour(Z, levels, hold='on', colors = 'r', origin='upper')
77-
axis(v)
78-
title("Image, origin 'upper'")
79-
80-
subplot(2,2,3)
81-
imshow(Z, origin='lower')
82-
v = axis()
83-
contour(Z, levels, hold='on', colors = 'r', origin='lower')
84-
axis(v)
85-
title("Image, origin 'lower'")
86-
87-
subplot(2,2,4)
88-
imshow(Z, interpolation='nearest')
89-
v = axis()
90-
contour(Z, levels, hold='on', colors = 'r', origin='image')
91-
axis(v)
92-
ylim = get(gca(), 'ylim')
93-
set(gca(), ylim=ylim[::-1])
94-
title("Image, origin from rc, reversed y-axis")
72+
levels = arange(-1.2,1.5,0.4)
73+
74+
figure()
75+
76+
77+
if fignum == 0:
78+
subplot(2,2,1)
79+
80+
if fignum == 0 or fignum == 1:
81+
levs1, colls = contourf(X, Y, Zbm, 10,
82+
cmap=cm.jet,
83+
badmask = Badmask
84+
)
85+
#If we want lines as well as filled regions, we need to call
86+
# contour separately; don't try to change the edgecolor or edgewidth
87+
# of the polygons in the collections returned by contourf.
88+
# Use levels output from previous call to guarantee they are the same.
89+
levs2, colls2 = contour(X, Y, Zbm, levs1,
90+
colors = 'k',
91+
badmask = Badmask,
92+
hold='on')
93+
# We don't really need dashed contour lines to indicate negative
94+
# regions, so let's turn them off.
95+
for c in colls2:
96+
c.set_linestyle('solid')
97+
98+
# It is easier here to make a separate call to contour than
99+
# to set up an array of colors and linewidths.
100+
levs3, colls3 = contour(X, Y, Zbm, (0,),
101+
colors = 'g',
102+
linewidths = 2,
103+
hold='on')
104+
title('Filled contours')
105+
colorbar()
106+
hot()
107+
# Major reworking of the colorbar mechanism is needed for filled contours!
108+
109+
if fignum == 0:
110+
subplot(2,2,2)
111+
112+
if fignum == 0 or fignum == 2:
113+
imshow(Z, extent=extent)
114+
v = axis()
115+
contour(Z, levels, hold='on', colors = 'k', origin='upper', extent=extent)
116+
axis(v)
117+
title("Image, origin 'upper'")
118+
119+
if fignum == 0:
120+
subplot(2,2,3)
121+
122+
if fignum == 0 or fignum == 3:
123+
imshow(Z, origin='lower', extent=extent)
124+
v = axis()
125+
contour(Z, levels, hold='on', colors = 'k', origin='lower', extent=extent)
126+
axis(v)
127+
title("Image, origin 'lower'")
128+
129+
if fignum == 0:
130+
subplot(2,2,4)
131+
132+
if fignum == 0 or fignum == 4:
133+
imshow(Z, interpolation='nearest', extent=extent)
134+
v = axis()
135+
contour(Z, levels, hold='on', colors = 'k', origin='image', extent=extent)
136+
axis(v)
137+
ylim = get(gca(), 'ylim')
138+
set(gca(), ylim=ylim[::-1])
139+
title("Image, origin from rc, reversed y-axis")
95140

96141
if options.save is not None:
97142
savefig(options.save)
98143

99144
show()
100-

lib/matplotlib/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
"""
142142
from __future__ import generators
143143

144-
__version__ = '0.73rc2'
144+
__version__ = '0.73rc3'
145145
__revision__ = '$Revision$'
146146
__date__ = '$Date$'
147147

0 commit comments

Comments
 (0)