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

Skip to content

Commit 969c613

Browse files
committed
fetched upstream
2 parents 7b35de2 + a9f242b commit 969c613

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed

examples/pylab_examples/axes_demo.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
#!/usr/bin/env python
2-
3-
from pylab import *
1+
import matplotlib.pyplot as plt
2+
import numpy as np
43

54
# create some data to use for the plot
65
dt = 0.001
7-
t = arange(0.0, 10.0, dt)
8-
r = exp(-t[:1000]/0.05) # impulse response
9-
x = randn(len(t))
10-
s = convolve(x, r)[:len(x)]*dt # colored noise
6+
t = np.arange(0.0, 10.0, dt)
7+
r = np.exp(-t[:1000]/0.05) # impulse response
8+
x = np.random.randn(len(t))
9+
s = np.convolve(x, r)[:len(x)]*dt # colored noise
1110

1211
# the main axes is subplot(111) by default
13-
plot(t, s)
14-
axis([0, 1, 1.1*amin(s), 2*amax(s)])
15-
xlabel('time (s)')
16-
ylabel('current (nA)')
17-
title('Gaussian colored noise')
12+
plt.plot(t, s)
13+
plt.axis([0, 1, 1.1*np.amin(s), 2*np.amax(s)])
14+
plt.xlabel('time (s)')
15+
plt.ylabel('current (nA)')
16+
plt.title('Gaussian colored noise')
1817

1918
# this is an inset axes over the main axes
20-
a = axes([.65, .6, .2, .2], axisbg='y')
21-
n, bins, patches = hist(s, 400, normed=1)
22-
title('Probability')
23-
setp(a, xticks=[], yticks=[])
19+
a = plt.axes([.65, .6, .2, .2], axisbg='y')
20+
n, bins, patches = plt.hist(s, 400, normed=1)
21+
plt.title('Probability')
22+
plt.xticks([])
23+
plt.yticks([])
2424

2525
# this is another inset axes over the main axes
26-
a = axes([0.2, 0.6, .2, .2], axisbg='y')
27-
plot(t[:len(r)], r)
28-
title('Impulse response')
29-
setp(a, xlim=(0, .2), xticks=[], yticks=[])
30-
26+
a = plt.axes([0.2, 0.6, .2, .2], axisbg='y')
27+
plt.plot(t[:len(r)], r)
28+
plt.title('Impulse response')
29+
plt.xlim(0, 0.2)
30+
plt.xticks([])
31+
plt.yticks([])
3132

32-
show()
33+
plt.show()

examples/pylab_examples/broken_axis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Broken axis example, where the y-axis will have a portion cut out.
33
"""
4-
import matplotlib.pylab as plt
4+
import matplotlib.pyplot as plt
55
import numpy as np
66

77

lib/matplotlib/backend_bases.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2813,15 +2813,14 @@ def mouse_move(self, event):
28132813
pass
28142814
else:
28152815
artists = event.inaxes.hitlist(event)
2816-
if event.inaxes.patch in artists:
2817-
artists.remove(event.inaxes.patch)
28182816

28192817
if artists:
2820-
artists.sort(key=lambda x: x.zorder)
2821-
a = artists[-1]
2822-
data = a.get_cursor_data(event)
2823-
if data is not None:
2824-
s += ' [%s]' % a.format_cursor_data(data)
2818+
a = max(enumerate(artists), key=lambda x: x[1].zorder)[1]
2819+
if a is not event.inaxes.patch:
2820+
data = a.get_cursor_data(event)
2821+
if data is not None:
2822+
s += ' [%s]' % a.format_cursor_data(data)
2823+
28252824
if len(self.mode):
28262825
self.set_message('%s, %s' % (self.mode, s))
28272826
else:

lib/matplotlib/transforms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
from .path import Path
5151

5252
DEBUG = False
53-
53+
# we need this later, but this is very expensive to set up
54+
MINFLOAT = np.MachAr(float).xmin
5455
MaskedArray = ma.MaskedArray
5556

5657

@@ -2738,7 +2739,7 @@ def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
27382739
swapped = True
27392740

27402741
maxabsvalue = max(abs(vmin), abs(vmax))
2741-
if maxabsvalue < (1e6 / tiny) * np.MachAr(float).xmin:
2742+
if maxabsvalue < (1e6 / tiny) * MINFLOAT:
27422743
vmin = -expander
27432744
vmax = expander
27442745

0 commit comments

Comments
 (0)