Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 32a2f79

Browse filesBrowse files
committed
Remove bivariate_norm from examples
1 parent 104e73a commit 32a2f79
Copy full SHA for 32a2f79
Expand file treeCollapse file tree

21 files changed

+108
-175
lines changed

‎examples/api/affine_image.py

Copy file name to clipboardExpand all lines: examples/api/affine_image.py
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"""
1010

1111
import numpy as np
12-
import matplotlib.mlab as mlab
1312
import matplotlib.pyplot as plt
1413
import matplotlib.transforms as mtransforms
1514

@@ -18,9 +17,9 @@ def get_image():
1817
delta = 0.25
1918
x = y = np.arange(-3.0, 3.0, delta)
2019
X, Y = np.meshgrid(x, y)
21-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
22-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
23-
Z = Z2 - Z1 # difference of Gaussians
20+
Z1 = np.exp(-X**2 - Y**2)
21+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
22+
Z = (Z1 - Z2)
2423
return Z
2524

2625

‎examples/frontpage/contour.py

Copy file name to clipboardExpand all lines: examples/frontpage/contour.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88

99
import matplotlib.pyplot as plt
1010
import numpy as np
11-
from matplotlib import mlab, cm
11+
from matplotlib import cm
1212

1313
extent = (-3, 3, -3, 3)
1414

1515
delta = 0.5
1616
x = np.arange(-3.0, 4.001, delta)
1717
y = np.arange(-4.0, 3.001, delta)
1818
X, Y = np.meshgrid(x, y)
19-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, -0.5)
20-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
21-
Z = (Z1 - Z2) * 10
19+
Z1 = np.exp(-X**2 - Y**2)
20+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
21+
Z = Z1 - Z2
2222

23-
levels = np.linspace(-2.0, 1.601, 40)
2423
norm = cm.colors.Normalize(vmax=abs(Z).max(), vmin=-abs(Z).max())
2524

2625
fig, ax = plt.subplots()
2726
cset1 = ax.contourf(
28-
X, Y, Z, levels,
27+
X, Y, Z, 40,
2928
norm=norm)
30-
ax.set_xlim(-3, 3)
31-
ax.set_ylim(-3, 3)
29+
ax.set_xlim(-2, 2)
30+
ax.set_ylim(-2, 2)
3231
ax.set_xticks([])
3332
ax.set_yticks([])
3433
fig.savefig("contour_frontpage.png", dpi=25) # results in 160x120 px image
34+
plt.show()

‎examples/images_contours_and_fields/contour_demo.py

Copy file name to clipboardExpand all lines: examples/images_contours_and_fields/contour_demo.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import matplotlib
1212
import numpy as np
1313
import matplotlib.cm as cm
14-
import matplotlib.mlab as mlab
1514
import matplotlib.pyplot as plt
1615

1716
matplotlib.rcParams['xtick.direction'] = 'out'
@@ -21,10 +20,9 @@
2120
x = np.arange(-3.0, 3.0, delta)
2221
y = np.arange(-2.0, 2.0, delta)
2322
X, Y = np.meshgrid(x, y)
24-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
25-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
26-
# difference of Gaussians
27-
Z = 10.0 * (Z2 - Z1)
23+
Z1 = np.exp(-X**2 - Y**2)
24+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
25+
Z = (Z1 - Z2) * 2
2826

2927
###############################################################################
3028
# Create a simple contour plot with labels using default colors. The

‎examples/images_contours_and_fields/contour_image.py

Copy file name to clipboardExpand all lines: examples/images_contours_and_fields/contour_image.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"""
1414
import matplotlib.pyplot as plt
1515
import numpy as np
16-
from matplotlib import mlab, cm
16+
from matplotlib import cm
1717

1818
# Default delta is large because that makes it fast, and it illustrates
1919
# the correct registration between image and contours.
@@ -24,9 +24,9 @@
2424
x = np.arange(-3.0, 4.001, delta)
2525
y = np.arange(-4.0, 3.001, delta)
2626
X, Y = np.meshgrid(x, y)
27-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
28-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
29-
Z = (Z1 - Z2) * 10
27+
Z1 = np.exp(-X**2 - Y**2)
28+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
29+
Z = (Z1 - Z2) * 2
3030

3131
# Boost the upper limit to avoid truncation errors.
3232
levels = np.arange(-2.0, 1.601, 0.4)

‎examples/images_contours_and_fields/contour_label_demo.py

Copy file name to clipboardExpand all lines: examples/images_contours_and_fields/contour_label_demo.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import matplotlib
1212
import numpy as np
1313
import matplotlib.cm as cm
14-
import matplotlib.mlab as mlab
1514
import matplotlib.ticker as ticker
1615
import matplotlib.pyplot as plt
1716

@@ -25,10 +24,9 @@
2524
x = np.arange(-3.0, 3.0, delta)
2625
y = np.arange(-2.0, 2.0, delta)
2726
X, Y = np.meshgrid(x, y)
28-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
29-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
30-
# difference of Gaussians
31-
Z = 10.0 * (Z2 - Z1)
27+
Z1 = np.exp(-X**2 - Y**2)
28+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
29+
Z = (Z1 - Z2) * 2
3230

3331
###############################################################################
3432
# Make contour labels using creative float classes

‎examples/images_contours_and_fields/contourf_demo.py

Copy file name to clipboardExpand all lines: examples/images_contours_and_fields/contourf_demo.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
x = y = np.arange(-3.0, 3.01, delta)
1616
X, Y = np.meshgrid(x, y)
17-
Z1 = plt.mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
18-
Z2 = plt.mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
19-
Z = 10 * (Z1 - Z2)
17+
Z1 = np.exp(-X**2 - Y**2)
18+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
19+
Z = (Z1 - Z2) * 2
2020

2121
nr, nc = Z.shape
2222

‎examples/images_contours_and_fields/contourf_log.py

Copy file name to clipboardExpand all lines: examples/images_contours_and_fields/contourf_log.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
import numpy as np
1111
from numpy import ma
1212
from matplotlib import ticker, cm
13-
from matplotlib.mlab import bivariate_normal
1413

1514
N = 100
1615
x = np.linspace(-3.0, 3.0, N)
1716
y = np.linspace(-2.0, 2.0, N)
1817

1918
X, Y = np.meshgrid(x, y)
2019

21-
# A low hump with a spike coming out of the top right.
20+
# A low hump with a spike coming out.
2221
# Needs to have z/colour axis on a log scale so we see both hump and spike.
2322
# linear scale only shows the spike.
24-
z = (bivariate_normal(X, Y, 0.1, 0.2, 1.0, 1.0)
25-
+ 0.1 * bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0))
23+
Z1 = np.exp(-(X)**2 - (Y)**2)
24+
Z2 = np.exp(-(X * 10)**2 - (Y * 10)**2)
25+
z = Z1 + 50 * Z2
2626

2727
# Put in some negative values (lower left corner) to cause trouble with logs:
2828
z[:5, :5] = -1
@@ -39,10 +39,10 @@
3939

4040
# Alternatively, you can manually set the levels
4141
# and the norm:
42-
#lev_exp = np.arange(np.floor(np.log10(z.min())-1),
42+
# lev_exp = np.arange(np.floor(np.log10(z.min())-1),
4343
# np.ceil(np.log10(z.max())+1))
44-
#levs = np.power(10, lev_exp)
45-
#cs = P.contourf(X, Y, z, levs, norm=colors.LogNorm())
44+
# levs = np.power(10, lev_exp)
45+
# cs = P.contourf(X, Y, z, levs, norm=colors.LogNorm())
4646

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

‎examples/images_contours_and_fields/image_demo.py

Copy file name to clipboardExpand all lines: examples/images_contours_and_fields/image_demo.py
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import numpy as np
1616
import matplotlib.cm as cm
17-
import matplotlib.mlab as mlab
1817
import matplotlib.pyplot as plt
1918
import matplotlib.cbook as cbook
2019
from matplotlib.path import Path
@@ -26,9 +25,9 @@
2625
delta = 0.025
2726
x = y = np.arange(-3.0, 3.0, delta)
2827
X, Y = np.meshgrid(x, y)
29-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
30-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
31-
Z = Z2 - Z1 # difference of Gaussians
28+
Z1 = np.exp(-X**2 - Y**2)
29+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
30+
Z = (Z1 - Z2) * 2
3231

3332
im = plt.imshow(Z, interpolation='bilinear', cmap=cm.RdYlGn,
3433
origin='lower', extent=[-3, 3, -3, 3],
@@ -156,9 +155,9 @@
156155
delta = 0.025
157156
x = y = np.arange(-3.0, 3.0, delta)
158157
X, Y = np.meshgrid(x, y)
159-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
160-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
161-
Z = Z2 - Z1 # difference of Gaussians
158+
Z1 = np.exp(-X**2 - Y**2)
159+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
160+
Z = (Z1 - Z2) * 2
162161

163162
path = Path([[0, 1], [1, 0], [0, -1], [-1, 0], [0, 1]])
164163
patch = PathPatch(path, facecolor='none')

‎examples/images_contours_and_fields/image_masked.py

Copy file name to clipboardExpand all lines: examples/images_contours_and_fields/image_masked.py
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@
1313
import numpy as np
1414
import matplotlib.pyplot as plt
1515
import matplotlib.colors as colors
16-
import matplotlib.mlab as mlab
1716

1817
# compute some interesting data
1918
x0, x1 = -5, 5
2019
y0, y1 = -3, 3
2120
x = np.linspace(x0, x1, 500)
2221
y = np.linspace(y0, y1, 500)
2322
X, Y = np.meshgrid(x, y)
24-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
25-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
26-
Z = 10*(Z2 - Z1) # difference of Gaussians
23+
Z1 = np.exp(-X**2 - Y**2)
24+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
25+
Z = (Z1 - Z2) * 2
2726

2827
# Set up a colormap:
2928
# use copy so that we do not mutate the global colormap instance

‎examples/images_contours_and_fields/pcolor_demo.py

Copy file name to clipboardExpand all lines: examples/images_contours_and_fields/pcolor_demo.py
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import matplotlib.pyplot as plt
1212
import numpy as np
1313
from matplotlib.colors import LogNorm
14-
from matplotlib.mlab import bivariate_normal
15-
1614

1715
###############################################################################
1816
# A simple pcolor demo
@@ -91,19 +89,20 @@
9189
N = 100
9290
X, Y = np.mgrid[-3:3:complex(0, N), -2:2:complex(0, N)]
9391

94-
# A low hump with a spike coming out of the top right.
92+
# A low hump with a spike coming out.
9593
# Needs to have z/colour axis on a log scale so we see both hump and spike.
9694
# linear scale only shows the spike.
97-
Z1 = (bivariate_normal(X, Y, 0.1, 0.2, 1.0, 1.0) +
98-
0.1 * bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0))
95+
Z1 = np.exp(-(X)**2 - (Y)**2)
96+
Z2 = np.exp(-(X * 10)**2 - (Y * 10)**2)
97+
Z = Z1 + 50 * Z2
9998

10099
fig, (ax0, ax1) = plt.subplots(2, 1)
101100

102-
c = ax0.pcolor(X, Y, Z1,
103-
norm=LogNorm(vmin=Z1.min(), vmax=Z1.max()), cmap='PuBu_r')
101+
c = ax0.pcolor(X, Y, Z,
102+
norm=LogNorm(vmin=Z.min(), vmax=Z.max()), cmap='PuBu_r')
104103
fig.colorbar(c, ax=ax0)
105104

106-
c = ax1.pcolor(X, Y, Z1, cmap='PuBu_r')
105+
c = ax1.pcolor(X, Y, Z, cmap='PuBu_r')
107106
fig.colorbar(c, ax=ax1)
108107

109108
plt.show()

‎examples/misc/demo_agg_filter.py

Copy file name to clipboardExpand all lines: examples/misc/demo_agg_filter.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import numpy as np
1010
import matplotlib.cm as cm
11-
import matplotlib.mlab as mlab
1211
import matplotlib.transforms as mtransforms
1312
from matplotlib.colors import LightSource
1413
from matplotlib.artist import Artist
@@ -187,10 +186,9 @@ def filtered_text(ax):
187186
x = np.arange(-3.0, 3.0, delta)
188187
y = np.arange(-2.0, 2.0, delta)
189188
X, Y = np.meshgrid(x, y)
190-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
191-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
192-
# difference of Gaussians
193-
Z = 10.0 * (Z2 - Z1)
189+
Z1 = np.exp(-X**2 - Y**2)
190+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
191+
Z = (Z1 - Z2) * 2
194192

195193
# draw
196194
im = ax.imshow(Z, interpolation='bilinear', origin='lower',

‎examples/misc/hyperlinks_sgskip.py

Copy file name to clipboardExpand all lines: examples/misc/hyperlinks_sgskip.py
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import numpy as np
1414
import matplotlib.cm as cm
15-
import matplotlib.mlab as mlab
1615
import matplotlib.pyplot as plt
1716

1817
###############################################################################
@@ -28,9 +27,9 @@
2827
delta = 0.025
2928
x = y = np.arange(-3.0, 3.0, delta)
3029
X, Y = np.meshgrid(x, y)
31-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
32-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
33-
Z = Z2 - Z1 # difference of Gaussians
30+
Z1 = np.exp(-X**2 - Y**2)
31+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
32+
Z = (Z1 - Z2) * 2
3433

3534
im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
3635
origin='lower', extent=[-3, 3, -3, 3])

‎examples/pyplots/whats_new_98_4_fill_between.py

Copy file name to clipboardExpand all lines: examples/pyplots/whats_new_98_4_fill_between.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
=============================
55
66
"""
7-
import matplotlib.mlab as mlab
87
import matplotlib.pyplot as plt
98
import numpy as np
109

‎examples/pyplots/whats_new_99_axes_grid.py

Copy file name to clipboardExpand all lines: examples/pyplots/whats_new_99_axes_grid.py
+10-11Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,31 @@
88
import matplotlib.pyplot as plt
99
from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
1010

11+
1112
def get_demo_image():
1213
# prepare image
1314
delta = 0.5
1415

15-
extent = (-3,4,-4,3)
16+
extent = (-3, 4, -4, 3)
1617
x = np.arange(-3.0, 4.001, delta)
1718
y = np.arange(-4.0, 3.001, delta)
1819
X, Y = np.meshgrid(x, y)
19-
import matplotlib.mlab as mlab
20-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
21-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
22-
Z = (Z1 - Z2) * 10
20+
Z1 = np.exp(-X**2 - Y**2)
21+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
22+
Z = (Z1 - Z2) * 2
2323

2424
return Z, extent
2525

2626

27-
2827
def get_rgb():
2928
Z, extent = get_demo_image()
3029

31-
Z[Z<0] = 0.
32-
Z = Z/Z.max()
30+
Z[Z < 0] = 0.
31+
Z = Z / Z.max()
3332

34-
R = Z[:13,:13]
35-
G = Z[2:,2:]
36-
B = Z[:13,2:]
33+
R = Z[:13, :13]
34+
G = Z[2:, 2:]
35+
B = Z[:13, 2:]
3736

3837
return R, G, B
3938

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.