Skip to content

Commit 1d6c4b3

Browse files
committed
backend driver fix
svn path=/trunk/matplotlib/; revision=5165
1 parent 7d7f073 commit 1d6c4b3

23 files changed

+122
-123
lines changed

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ clean:
1515
rm -f *.png *.ps *.eps *.svg *.jpg *.pdf
1616
find . -name "_tmp*.py" | xargs rm -f;\
1717
find . \( -name "*~" -o -name "*.pyc" \) | xargs rm -f;\
18-
find examples \( -name "*.svg" C-o -name "*.png" -o -name "*.pdf" -o -name "*.ps" -o -name "*.eps" -o -name "*.tar" -o -name "*.gz" -o -name "*.log" -o -name "*.aux" -o -name "*.tex" \) | xargs rm -f
1918
find unit \( -name "*.png" -o -name "*.ps" -o -name "*.pdf" -o -name "*.eps" \) | xargs rm -f
2019
find . \( -name "#*" -o -name ".#*" -o -name ".*~" -o -name "*~" \) | xargs rm -f
2120

examples/pylab/agg_buffer_to_array.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import matplotlib
22
matplotlib.use('Agg')
33
from pylab import figure, show
4-
import numpy as npy
4+
import numpy as np
55

66
# make an agg figure
77
fig = figure()
@@ -13,7 +13,7 @@
1313
# grab rhe pixel buffer and dumpy it into a numpy array
1414
buf = fig.canvas.buffer_rgba(0,0)
1515
l, b, w, h = fig.bbox.bounds
16-
X = npy.fromstring(buf, npy.uint8)
16+
X = np.fromstring(buf, np.uint8)
1717
X.shape = h,w,4
1818

1919
# now display the array X as an Axes in a new figure

examples/pylab/annotation_demo.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
from matplotlib.pyplot import figure, show
3737
from matplotlib.patches import Ellipse
38-
import numpy as npy
38+
import numpy as np
3939

4040

4141
if 1:
@@ -44,8 +44,8 @@
4444
fig = figure()
4545
ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5), ylim=(-3,5))
4646

47-
t = npy.arange(0.0, 5.0, 0.01)
48-
s = npy.cos(2*npy.pi*t)
47+
t = np.arange(0.0, 5.0, 0.01)
48+
s = np.cos(2*np.pi*t)
4949
line, = ax.plot(t, s, lw=3, color='purple')
5050

5151
ax.annotate('axes center', xy=(.5, .5), xycoords='axes fraction',
@@ -94,8 +94,8 @@
9494
# respected
9595
fig = figure()
9696
ax = fig.add_subplot(111, polar=True)
97-
r = npy.arange(0,1,0.001)
98-
theta = 2*2*npy.pi*r
97+
r = np.arange(0,1,0.001)
98+
theta = 2*2*np.pi*r
9999
line, = ax.plot(theta, r, color='#ee8d18', lw=3)
100100

101101
ind = 800
@@ -124,8 +124,8 @@
124124
ax.add_artist(el)
125125
el.set_clip_box(ax.bbox)
126126
ax.annotate('the top',
127-
xy=(npy.pi/2., 10.), # theta, radius
128-
xytext=(npy.pi/3, 20.), # theta, radius
127+
xy=(np.pi/2., 10.), # theta, radius
128+
xytext=(np.pi/3, 20.), # theta, radius
129129
xycoords='polar',
130130
textcoords='polar',
131131
arrowprops=dict(facecolor='black', shrink=0.05),

examples/pylab/clippedline.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66
from matplotlib.lines import Line2D
7-
import numpy as npy
7+
import numpy as np
88
from pylab import figure, show
99

1010
class ClippedLine(Line2D):
@@ -19,13 +19,13 @@ def __init__(self, ax, *args, **kwargs):
1919

2020
def set_data(self, *args, **kwargs):
2121
Line2D.set_data(self, *args, **kwargs)
22-
self.xorig = npy.array(self._x)
23-
self.yorig = npy.array(self._y)
22+
self.xorig = np.array(self._x)
23+
self.yorig = np.array(self._y)
2424

2525
def draw(self, renderer):
2626
xlim = self.ax.get_xlim()
2727

28-
ind0, ind1 = npy.searchsorted(self.xorig, xlim)
28+
ind0, ind1 = np.searchsorted(self.xorig, xlim)
2929
self._x = self.xorig[ind0:ind1]
3030
self._y = self.yorig[ind0:ind1]
3131
N = len(self._x)
@@ -43,8 +43,8 @@ def draw(self, renderer):
4343
fig = figure()
4444
ax = fig.add_subplot(111, autoscale_on=False)
4545

46-
t = npy.arange(0.0, 100.0, 0.01)
47-
s = npy.sin(2*npy.pi*t)
46+
t = np.arange(0.0, 100.0, 0.01)
47+
s = np.sin(2*np.pi*t)
4848
line = ClippedLine(ax, t, s, color='g', ls='-', lw=2)
4949
ax.add_line(line)
5050
ax.set_xlim(10,30)

examples/pylab/colours.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"""
33
Some simple functions to generate colours.
44
"""
5-
import numpy as npy
5+
import numpy as np
66
from matplotlib.colors import colorConverter
77

88
def pastel(colour, weight=2.4):
99
""" Convert colour into a nice pastel shade"""
10-
rgb = npy.asarray(colorConverter.to_rgb(colour))
10+
rgb = np.asarray(colorConverter.to_rgb(colour))
1111
# scale colour
1212
maxc = max(rgb)
1313
if maxc < 1.0 and maxc > 0:
@@ -31,7 +31,7 @@ def pastel(colour, weight=2.4):
3131

3232
def get_colours(n):
3333
""" Return n pastel colours. """
34-
base = npy.asarray([[1,0,0], [0,1,0], [0,0,1]])
34+
base = np.asarray([[1,0,0], [0,1,0], [0,0,1]])
3535

3636
if n <= 3:
3737
return base[0:n]
@@ -42,7 +42,7 @@ def get_colours(n):
4242

4343
colours = []
4444
for start in (0, 1):
45-
for x in npy.linspace(0, 1, needed[start]+2):
45+
for x in np.linspace(0, 1, needed[start]+2):
4646
colours.append((base[start] * (1.0 - x)) +
4747
(base[start+1] * x))
4848

examples/pylab/contourf_log.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
'''
44

55
from matplotlib import pyplot as P
6-
import numpy as npy
6+
import numpy as np
77
from numpy import ma
88
from matplotlib import colors, ticker
99
from matplotlib.mlab import bivariate_normal
1010

1111
N = 100
12-
x = npy.linspace(-3.0, 3.0, N)
13-
y = npy.linspace(-2.0, 2.0, N)
12+
x = np.linspace(-3.0, 3.0, N)
13+
y = np.linspace(-2.0, 2.0, N)
1414

15-
X, Y = npy.meshgrid(x, y)
15+
X, Y = np.meshgrid(x, y)
1616

1717
# A low hump with a spike coming out of the top right.
1818
# Needs to have z/colour axis on a log scale so we see both hump and spike.
@@ -34,9 +34,9 @@
3434

3535
# Alternatively, you can manually set the levels
3636
# and the norm:
37-
#lev_exp = npy.arange(npy.floor(npy.log10(z.min())-1),
38-
# npy.ceil(npy.log10(z.max())+1))
39-
#levs = npy.power(10, lev_exp)
37+
#lev_exp = np.arange(np.floor(np.log10(z.min())-1),
38+
# np.ceil(np.log10(z.max())+1))
39+
#levs = np.power(10, lev_exp)
4040
#cs = P.contourf(X, Y, z, levs, norm=colors.LogNorm())
4141

4242
#The 'extend' kwarg does not work yet with a log scale.

examples/pylab/custom_projection_example.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
BboxTransformTo, IdentityTransform, Transform, TransformWrapper
88
from matplotlib.projections import register_projection
99

10-
import numpy as npy
10+
import numpy as np
1111

1212
# This example projection class is rather long, but it is designed to
1313
# illustrate many features, not all of which will be used every time.
@@ -60,8 +60,8 @@ def cla(self):
6060
# be changed by the user. This makes the math in the
6161
# transformation itself easier, and since this is a toy
6262
# example, the easier, the better.
63-
Axes.set_xlim(self, -npy.pi, npy.pi)
64-
Axes.set_ylim(self, -npy.pi / 2.0, npy.pi / 2.0)
63+
Axes.set_xlim(self, -np.pi, np.pi)
64+
Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0)
6565

6666
def cla(self):
6767
"""
@@ -79,8 +79,8 @@ def cla(self):
7979

8080
# self.grid(rcParams['axes.grid'])
8181

82-
Axes.set_xlim(self, -npy.pi, npy.pi)
83-
Axes.set_ylim(self, -npy.pi / 2.0, npy.pi / 2.0)
82+
Axes.set_xlim(self, -np.pi, np.pi)
83+
Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0)
8484

8585
def _set_lim_and_transforms(self):
8686
"""
@@ -117,8 +117,8 @@ def _set_lim_and_transforms(self):
117117
# within the axes. The peculiar calculations of xscale and
118118
# yscale are specific to a Aitoff-Hammer projection, so don't
119119
# worry about them too much.
120-
xscale = 2.0 * npy.sqrt(2.0) * npy.sin(0.5 * npy.pi)
121-
yscale = npy.sqrt(2.0) * npy.sin(0.5 * npy.pi)
120+
xscale = 2.0 * np.sqrt(2.0) * np.sin(0.5 * np.pi)
121+
yscale = np.sqrt(2.0) * np.sin(0.5 * np.pi)
122122
self.transAffine = Affine2D() \
123123
.scale(0.5 / xscale, 0.5 / yscale) \
124124
.translate(0.5, 0.5)
@@ -148,8 +148,8 @@ def _set_lim_and_transforms(self):
148148
# pixels from the equator.
149149
self._xaxis_pretransform = \
150150
Affine2D() \
151-
.scale(1.0, npy.pi) \
152-
.translate(0.0, -npy.pi)
151+
.scale(1.0, np.pi) \
152+
.translate(0.0, -np.pi)
153153
self._xaxis_transform = \
154154
self._xaxis_pretransform + \
155155
self.transData
@@ -168,7 +168,7 @@ def _set_lim_and_transforms(self):
168168
# (1, ymax). The goal of these transforms is to go from that
169169
# space to display space. The tick labels will be offset 4
170170
# pixels from the edge of the axes ellipse.
171-
yaxis_stretch = Affine2D().scale(npy.pi * 2.0, 1.0).translate(-npy.pi, 0.0)
171+
yaxis_stretch = Affine2D().scale(np.pi * 2.0, 1.0).translate(-np.pi, 0.0)
172172
yaxis_space = Affine2D().scale(1.0, 1.1)
173173
self._yaxis_transform = \
174174
yaxis_stretch + \
@@ -265,8 +265,8 @@ def set_yscale(self, *args, **kwargs):
265265
# set_xlim and set_ylim to ignore any input. This also applies to
266266
# interactive panning and zooming in the GUI interfaces.
267267
def set_xlim(self, *args, **kwargs):
268-
Axes.set_xlim(self, -npy.pi, npy.pi)
269-
Axes.set_ylim(self, -npy.pi / 2.0, npy.pi / 2.0)
268+
Axes.set_xlim(self, -np.pi, np.pi)
269+
Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0)
270270
set_ylim = set_xlim
271271

272272
def format_coord(self, long, lat):
@@ -276,8 +276,8 @@ def format_coord(self, long, lat):
276276
277277
In this case, we want them to be displayed in degrees N/S/E/W.
278278
"""
279-
long = long * (180.0 / npy.pi)
280-
lat = lat * (180.0 / npy.pi)
279+
long = long * (180.0 / np.pi)
280+
lat = lat * (180.0 / np.pi)
281281
if lat >= 0.0:
282282
ns = 'N'
283283
else:
@@ -298,7 +298,7 @@ def __init__(self, round_to=1.0):
298298
self._round_to = round_to
299299

300300
def __call__(self, x, pos=None):
301-
degrees = (x / npy.pi) * 180.0
301+
degrees = (x / np.pi) * 180.0
302302
degrees = round(degrees / self._round_to) * self._round_to
303303
# \u00b0 : degree symbol
304304
return u"%d\u00b0" % degrees
@@ -316,7 +316,7 @@ class -- it provides a more convenient interface to set the
316316
number = (360.0 / degrees) + 1
317317
self.xaxis.set_major_locator(
318318
FixedLocator(
319-
npy.linspace(-npy.pi, npy.pi, number, True)[1:-1]))
319+
np.linspace(-np.pi, np.pi, number, True)[1:-1]))
320320
# Set the formatter to display the tick labels in degrees,
321321
# rather than radians.
322322
self.xaxis.set_major_formatter(self.DegreeFormatter(degrees))
@@ -334,7 +334,7 @@ class -- it provides a more convenient interface than
334334
number = (180.0 / degrees) + 1
335335
self.yaxis.set_major_locator(
336336
FixedLocator(
337-
npy.linspace(-npy.pi / 2.0, npy.pi / 2.0, number, True)[1:-1]))
337+
np.linspace(-np.pi / 2.0, np.pi / 2.0, number, True)[1:-1]))
338338
# Set the formatter to display the tick labels in degrees,
339339
# rather than radians.
340340
self.yaxis.set_major_formatter(self.DegreeFormatter(degrees))
@@ -351,7 +351,7 @@ def set_longitude_grid_ends(self, degrees):
351351
class -- it provides an interface to something that has no
352352
analogy in the base Axes class.
353353
"""
354-
longitude_cap = degrees * (npy.pi / 180.0)
354+
longitude_cap = degrees * (np.pi / 180.0)
355355
# Change the xaxis gridlines transform so that it draws from
356356
# -degrees to degrees, rather than -pi to pi.
357357
self._xaxis_pretransform \
@@ -412,13 +412,13 @@ def transform(self, ll):
412412

413413
# Pre-compute some values
414414
half_long = longitude / 2.0
415-
cos_latitude = npy.cos(latitude)
416-
sqrt2 = npy.sqrt(2.0)
415+
cos_latitude = np.cos(latitude)
416+
sqrt2 = np.sqrt(2.0)
417417

418-
alpha = 1.0 + cos_latitude * npy.cos(half_long)
419-
x = (2.0 * sqrt2) * (cos_latitude * npy.sin(half_long)) / alpha
420-
y = (sqrt2 * npy.sin(latitude)) / alpha
421-
return npy.concatenate((x, y), 1)
418+
alpha = 1.0 + cos_latitude * np.cos(half_long)
419+
x = (2.0 * sqrt2) * (cos_latitude * np.sin(half_long)) / alpha
420+
y = (sqrt2 * np.sin(latitude)) / alpha
421+
return np.concatenate((x, y), 1)
422422

423423
# This is where things get interesting. With this projection,
424424
# straight lines in data space become curves in display space.
@@ -451,10 +451,10 @@ def transform(self, xy):
451451

452452
quarter_x = 0.25 * x
453453
half_y = 0.5 * y
454-
z = npy.sqrt(1.0 - quarter_x*quarter_x - half_y*half_y)
455-
longitude = 2 * npy.arctan((z*x) / (2.0 * (2.0*z*z - 1.0)))
456-
latitude = npy.arcsin(y*z)
457-
return npy.concatenate((longitude, latitude), 1)
454+
z = np.sqrt(1.0 - quarter_x*quarter_x - half_y*half_y)
455+
longitude = 2 * np.arctan((z*x) / (2.0 * (2.0*z*z - 1.0)))
456+
latitude = np.arcsin(y*z)
457+
return np.concatenate((longitude, latitude), 1)
458458
transform.__doc__ = Transform.transform.__doc__
459459

460460
def inverted(self):

examples/pylab/custom_scale_example.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def __init__(self, axis, **kwargs):
3636
thresh: The degree above which to crop the data.
3737
"""
3838
mscale.ScaleBase.__init__(self)
39-
thresh = kwargs.pop("thresh", (85 / 180.0) * npy.pi)
40-
if thresh >= npy.pi / 2.0:
39+
thresh = kwargs.pop("thresh", (85 / 180.0) * np.pi)
40+
if thresh >= np.pi / 2.0:
4141
raise ValueError("thresh must be less than pi/2")
4242
self.thresh = thresh
4343

@@ -67,11 +67,11 @@ def set_default_locators_and_formatters(self, axis):
6767
class DegreeFormatter(Formatter):
6868
def __call__(self, x, pos=None):
6969
# \u00b0 : degree symbol
70-
return u"%d\u00b0" % ((x / npy.pi) * 180.0)
70+
return u"%d\u00b0" % ((x / np.pi) * 180.0)
7171

72-
deg2rad = npy.pi / 180.0
72+
deg2rad = np.pi / 180.0
7373
axis.set_major_locator(FixedLocator(
74-
npy.arange(-90, 90, 10) * deg2rad))
74+
np.arange(-90, 90, 10) * deg2rad))
7575
axis.set_major_formatter(DegreeFormatter())
7676
axis.set_minor_formatter(DegreeFormatter())
7777

@@ -118,9 +118,9 @@ def transform(self, a):
118118
"""
119119
masked = ma.masked_where((a < -self.thresh) | (a > self.thresh), a)
120120
if masked.mask.any():
121-
return ma.log(npy.abs(ma.tan(masked) + 1.0 / ma.cos(masked)))
121+
return ma.log(np.abs(ma.tan(masked) + 1.0 / ma.cos(masked)))
122122
else:
123-
return npy.log(npy.abs(npy.tan(a) + 1.0 / npy.cos(a)))
123+
return np.log(np.abs(np.tan(a) + 1.0 / np.cos(a)))
124124

125125
def inverted(self):
126126
"""
@@ -139,7 +139,7 @@ def __init__(self, thresh):
139139
self.thresh = thresh
140140

141141
def transform(self, a):
142-
return npy.arctan(npy.sinh(a))
142+
return np.arctan(np.sinh(a))
143143

144144
def inverted(self):
145145
return MercatorLatitudeScale.MercatorLatitudeTransform(self.thresh)
@@ -149,10 +149,10 @@ def inverted(self):
149149
mscale.register_scale(MercatorLatitudeScale)
150150

151151
from pylab import *
152-
import numpy as npy
152+
import numpy as np
153153

154154
t = arange(-180.0, 180.0, 0.1)
155-
s = t / 360.0 * npy.pi
155+
s = t / 360.0 * np.pi
156156

157157
plot(t, s, '-', lw=2)
158158
gca().set_yscale('mercator')

0 commit comments

Comments
 (0)