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 0e07fd2

Browse filesBrowse files
committed
2.0 Examples fixes. See #6762
These are fixes for all issues found in axes_grid, color, and event_handling sections on the examples page. axis_grid/demo_colorbar_with_inset_locator.py - changed interpolation from the default(previously bilinear now none) to 'bilinear' to match 1.5.1 example axes_grid1/simple_axesgrid.py - set interpolation to bilinear axisartist/demo_curvelinear_grid.py - Set linewidth=2.0 and grid zorder=0 so the plotted lines actually visible event_handling/keypress_demo.py - added usage instruction as axes title event_handling/lasso_demo.py - added usage instruction as axes title event_handling/looking_glass.py - added usage instruction as axes title event_handling/resample.py - removed gtk and hardcoded wave file dependencies and just created a sample signal within the script event_handling/trifinder_event_demo.py - zip(l1,l2) call changed to list(zip(l1,l2)) to be python3 compatible event_handling/viewlims.py - The focus box that is supposed to appear in the left axes when user zooms in the right axes wasn't visible. Set linewidth=1.0
1 parent d527799 commit 0e07fd2
Copy full SHA for 0e07fd2

File tree

Expand file treeCollapse file tree

9 files changed

+25
-24
lines changed
Filter options
Expand file treeCollapse file tree

9 files changed

+25
-24
lines changed

‎examples/axes_grid1/demo_colorbar_with_inset_locator.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/demo_colorbar_with_inset_locator.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
height="5%", # height : 50%
1010
loc=1)
1111

12-
im1 = ax1.imshow([[1, 2], [2, 3]])
12+
im1 = ax1.imshow([[1, 2], [2, 3]], interpolation='bilinear')
1313
plt.colorbar(im1, cax=axins1, orientation="horizontal", ticks=[1, 2, 3])
1414
axins1.xaxis.set_ticks_position("bottom")
1515

@@ -26,7 +26,7 @@
2626
# of the legend. you may want to play with the borderpad value and
2727
# the bbox_to_anchor coordinate.
2828

29-
im = ax2.imshow([[1, 2], [2, 3]])
29+
im = ax2.imshow([[1, 2], [2, 3]], interpolation='bilinear')
3030
plt.colorbar(im, cax=axins, ticks=[1, 2, 3])
3131

3232
plt.draw()

‎examples/axes_grid1/simple_axesgrid.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/simple_axesgrid.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
)
1313

1414
for i in range(4):
15-
grid[i].imshow(im) # The AxesGrid object work as a list of axes.
15+
grid[i].imshow(im, interpolation='bilinear') # The AxesGrid object work as a list of axes.
1616

1717
plt.show()

‎examples/axisartist/demo_curvelinear_grid.py

Copy file name to clipboardExpand all lines: examples/axisartist/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
@@ -21,5 +21,5 @@ def press(event):
2121

2222
ax.plot(np.random.rand(12), np.random.rand(12), 'go')
2323
xl = ax.set_xlabel('easy come, easy go')
24-
24+
ax.set_title('Press a key')
2525
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
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

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

1515
class EventHandler(object):
1616
def __init__(self):

‎examples/event_handling/resample.py

Copy file name to clipboard
+10-12Lines changed: 10 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,21 +31,21 @@ 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
5147
ax.callbacks.connect('xlim_changed', d.update)
5248

5349
plt.show()
50+
51+

‎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.