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 8396451

Browse filesBrowse files
committed
Merge pull request #6786 from mlub/examplestesting
DOC: 2.0 Examples fixes See #6762
1 parent e2b1184 commit 8396451
Copy full SHA for 8396451

File tree

Expand file treeCollapse file tree

7 files changed

+20
-20
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+20
-20
lines changed

‎examples/axes_grid/demo_curvelinear_grid.py

Copy file name to clipboardExpand all lines: examples/axes_grid/demo_curvelinear_grid.py
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ def inv_tr(x, y):
3434
fig.add_subplot(ax1)
3535

3636
xx, yy = tr([3, 6], [5.0, 10.])
37-
ax1.plot(xx, yy)
37+
ax1.plot(xx, yy, linewidth=2.0)
3838

3939
ax1.set_aspect(1.)
4040
ax1.set_xlim(0, 10.)
4141
ax1.set_ylim(0, 10.)
4242

4343
ax1.axis["t"] = ax1.new_floating_axis(0, 3.)
4444
ax1.axis["t2"] = ax1.new_floating_axis(1, 7.)
45-
ax1.grid(True)
45+
ax1.grid(True, zorder=0)
4646

4747

4848
import mpl_toolkits.axisartist.angle_helper as angle_helper
@@ -107,13 +107,14 @@ def curvelinear_test2(fig):
107107
ax1.parasites.append(ax2)
108108
intp = cbook.simple_linear_interpolation
109109
ax2.plot(intp(np.array([0, 30]), 50),
110-
intp(np.array([10., 10.]), 50))
110+
intp(np.array([10., 10.]), 50),
111+
linewidth=2.0)
111112

112113
ax1.set_aspect(1.)
113114
ax1.set_xlim(-5, 12)
114115
ax1.set_ylim(-5, 10)
115116

116-
ax1.grid(True)
117+
ax1.grid(True, zorder=0)
117118

118119
if 1:
119120
fig = plt.figure(1, figsize=(7, 4))

‎examples/event_handling/keypress_demo.py

Copy file name to clipboardExpand all lines: examples/event_handling/keypress_demo.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ def press(event):
2323

2424
ax.plot(np.random.rand(12), np.random.rand(12), 'go')
2525
xl = ax.set_xlabel('easy come, easy go')
26-
26+
ax.set_title('Press a key')
2727
plt.show()

‎examples/event_handling/lasso_demo.py

Copy file name to clipboardExpand all lines: examples/event_handling/lasso_demo.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ def onpress(self, event):
7777
if __name__ == '__main__':
7878

7979
data = [Datum(*xy) for xy in rand(100, 2)]
80-
8180
ax = plt.axes(xlim=(0, 1), ylim=(0, 1), autoscale_on=False)
81+
ax.set_title('Lasso points using left mouse button')
82+
8283
lman = LassoManager(ax, data)
8384

8485
plt.show()

‎examples/event_handling/looking_glass.py

Copy file name to clipboardExpand all lines: examples/event_handling/looking_glass.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
ax.plot(x, y, alpha=0.2)
1212
line, = ax.plot(x, y, alpha=1.0, clip_path=circ)
13+
ax.set_title("Left click and drag to move looking glass")
1314

1415

1516
class EventHandler(object):

‎examples/event_handling/resample.py

Copy file name to clipboardExpand all lines: examples/event_handling/resample.py
+8-12Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
import numpy as np
22
import matplotlib.pyplot as plt
3-
from scikits.audiolab import wavread
43

54

65
# A class that will downsample the data and recompute when zoomed.
76
class DataDisplayDownsampler(object):
87
def __init__(self, xdata, ydata):
98
self.origYData = ydata
109
self.origXData = xdata
11-
self.numpts = 3000
10+
self.ratio = 5
1211
self.delta = xdata[-1] - xdata[0]
1312

14-
def resample(self, xstart, xend):
13+
def downsample(self, xstart, xend):
1514
# Very simple downsampling that takes the points within the range
1615
# and picks every Nth point
1716
mask = (self.origXData > xstart) & (self.origXData < xend)
1817
xdata = self.origXData[mask]
19-
ratio = int(xdata.size / self.numpts) + 1
20-
xdata = xdata[::ratio]
18+
xdata = xdata[::self.ratio]
2119

2220
ydata = self.origYData[mask]
23-
ydata = ydata[::ratio]
21+
ydata = ydata[::self.ratio]
2422

2523
return xdata, ydata
2624

@@ -33,18 +31,16 @@ def update(self, ax):
3331
self.line.set_data(*self.downsample(xstart, xend))
3432
ax.figure.canvas.draw_idle()
3533

36-
# Read data
37-
data = wavread('/usr/share/sounds/purple/receive.wav')[0]
38-
ydata = np.tile(data[:, 0], 100)
39-
xdata = np.arange(ydata.size)
34+
# Create a signal
35+
xdata = np.linspace(16, 365, 365-16)
36+
ydata = np.sin(2*np.pi*xdata/153) + np.cos(2*np.pi*xdata/127)
4037

4138
d = DataDisplayDownsampler(xdata, ydata)
4239

4340
fig, ax = plt.subplots()
4441

4542
# Hook up the line
46-
xdata, ydata = d.downsample(xdata[0], xdata[-1])
47-
d.line, = ax.plot(xdata, ydata)
43+
d.line, = ax.plot(xdata, ydata, 'o-')
4844
ax.set_autoscale_on(False) # Otherwise, infinite loop
4945

5046
# Connect for changing the view limits

‎examples/event_handling/trifinder_event_demo.py

Copy file name to clipboardExpand all lines: examples/event_handling/trifinder_event_demo.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def update_polygon(tri):
1717
points = triangulation.triangles[tri]
1818
xs = triangulation.x[points]
1919
ys = triangulation.y[points]
20-
polygon.set_xy(zip(xs, ys))
20+
polygon.set_xy(list(zip(xs, ys)))
2121

2222

2323
def motion_notify(event):

‎examples/event_handling/viewlims.py

Copy file name to clipboardExpand all lines: examples/event_handling/viewlims.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def ax_update(self, ax):
6464
ax1.imshow(Z, origin='lower', extent=(md.x.min(), md.x.max(), md.y.min(), md.y.max()))
6565
ax2.imshow(Z, origin='lower', extent=(md.x.min(), md.x.max(), md.y.min(), md.y.max()))
6666

67-
rect = UpdatingRect([0, 0], 0, 0, facecolor='None', edgecolor='black')
67+
rect = UpdatingRect([0, 0], 0, 0, facecolor='None', edgecolor='black', linewidth=1.0)
6868
rect.set_bounds(*ax2.viewLim.bounds)
6969
ax1.add_patch(rect)
7070

@@ -74,5 +74,6 @@ def ax_update(self, ax):
7474

7575
ax2.callbacks.connect('xlim_changed', md.ax_update)
7676
ax2.callbacks.connect('ylim_changed', md.ax_update)
77+
ax2.set_title("Zoom here")
7778

7879
plt.show()

0 commit comments

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