Skip to content

Commit 8fa7011

Browse files
committed
Merge remote-tracking branch 'matplotlib/master'
2 parents 024c96b + f8b671f commit 8fa7011

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed
Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
#!/usr/bin/env python
2-
'''imshow with masked array input and out-of-range colors.
1+
"""
2+
imshow with masked array input and out-of-range colors.
33
4-
The second subplot illustrates the use of BoundaryNorm to
5-
get a filled contour effect.
6-
'''
4+
The second subplot illustrates the use of BoundaryNorm to
5+
get a filled contour effect.
6+
"""
77

8-
from pylab import *
98
from numpy import ma
109
import matplotlib.colors as colors
10+
import matplotlib.pyplot as plt
11+
import matplotlib.mlab as mlab
12+
import numpy as np
1113

1214
delta = 0.025
13-
x = y = arange(-3.0, 3.0, delta)
14-
X, Y = meshgrid(x, y)
15-
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
16-
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
15+
x = y = np.arange(-3.0, 3.0, delta)
16+
X, Y = np.meshgrid(x, y)
17+
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
18+
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
1719
Z = 10*(Z2 - Z1) # difference of Gaussians
1820

1921
# Set up a colormap:
20-
palette = cm.gray
22+
palette = plt.cm.gray
2123
palette.set_over('r', 1.0)
2224
palette.set_under('g', 1.0)
2325
palette.set_bad('b', 1.0)
@@ -33,22 +35,22 @@
3335
# range to which the regular palette color scale is applied.
3436
# Anything above that range is colored based on palette.set_over, etc.
3537

36-
subplot(1, 2, 1)
37-
im = imshow(Zm, interpolation='bilinear',
38-
cmap=palette,
39-
norm=colors.Normalize(vmin=-1.0, vmax=1.0, clip=False),
40-
origin='lower', extent=[-3, 3, -3, 3])
41-
title('Green=low, Red=high, Blue=bad')
42-
colorbar(im, extend='both', orientation='horizontal', shrink=0.8)
43-
44-
subplot(1, 2, 2)
45-
im = imshow(Zm, interpolation='nearest',
46-
cmap=palette,
47-
norm=colors.BoundaryNorm([-1, -0.5, -0.2, 0, 0.2, 0.5, 1],
48-
ncolors=256, clip=False),
49-
origin='lower', extent=[-3, 3, -3, 3])
50-
title('With BoundaryNorm')
51-
colorbar(im, extend='both', spacing='proportional',
52-
orientation='horizontal', shrink=0.8)
53-
54-
show()
38+
plt.subplot(1, 2, 1)
39+
im = plt.imshow(Zm, interpolation='bilinear',
40+
cmap=palette,
41+
norm=colors.Normalize(vmin=-1.0, vmax=1.0, clip=False),
42+
origin='lower', extent=[-3, 3, -3, 3])
43+
plt.title('Green=low, Red=high, Blue=bad')
44+
plt.colorbar(im, extend='both', orientation='horizontal', shrink=0.8)
45+
46+
plt.subplot(1, 2, 2)
47+
im = plt.imshow(Zm, interpolation='nearest',
48+
cmap=palette,
49+
norm=colors.BoundaryNorm([-1, -0.5, -0.2, 0, 0.2, 0.5, 1],
50+
ncolors=256, clip=False),
51+
origin='lower', extent=[-3, 3, -3, 3])
52+
plt.title('With BoundaryNorm')
53+
plt.colorbar(im, extend='both', spacing='proportional',
54+
orientation='horizontal', shrink=0.8)
55+
56+
plt.show()
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
#!/usr/bin/env python
21
"""
32
You can specify whether images should be plotted with the array origin
43
x[0,0] in the upper left or upper right by using the origin parameter.
54
You can also control the default be setting image.origin in your
65
matplotlibrc file; see http://matplotlib.org/matplotlibrc
76
"""
8-
from pylab import *
7+
import matplotlib.pyplot as plt
8+
import numpy as np
99

10-
x = arange(100.0)
10+
x = np.arange(100.0)
1111
x.shape = (10, 10)
1212

1313
interp = 'bilinear'
1414
#interp = 'nearest'
1515
lim = -2, 11, -2, 6
16-
subplot(211, axisbg='g')
17-
title('blue should be up')
18-
imshow(x, origin='upper', interpolation=interp)
19-
#axis(lim)
16+
plt.subplot(211, axisbg='g')
17+
plt.title('blue should be up')
18+
plt.imshow(x, origin='upper', interpolation=interp, cmap='jet')
19+
#plt.axis(lim)
2020

21-
subplot(212, axisbg='y')
22-
title('blue should be down')
23-
imshow(x, origin='lower', interpolation=interp)
24-
#axis(lim)
25-
show()
21+
plt.subplot(212, axisbg='y')
22+
plt.title('blue should be down')
23+
plt.imshow(x, origin='lower', interpolation=interp, cmap='jet')
24+
#plt.axis(lim)
25+
plt.show()

0 commit comments

Comments
 (0)