8000 Merge remote-tracking branch 'matplotlib/master' into mep12-image_ori… · matplotlib/matplotlib@ab4c9ea · GitHub
[go: up one dir, main page]

Skip to content

Commit ab4c9ea

Browse files
committed
Merge remote-tracking branch 'matplotlib/master' into mep12-image_origin.py
2 parents dba973e + 3f3b92f commit ab4c9ea

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
#!/usr/bin/env python
21
"""
3-
42
You can use decreasing axes by flipping the normal order of the axis
53
limits
6-
74
"""
8-
from pylab import *
95

10-
t = arange(0.01, 5.0, 0.01)
11-
s = exp(-t)
12-
plot(t, s)
6+
import matplotlib.pyplot as plt
7+
import numpy as np
8+
9+
t = np.arange(0.01, 5.0, 0.01)
10+
s = np.exp(-t)
11+
plt.plot(t, s)
1312

14-
xlim(5, 0) # decreasing time
13+
plt.xlim(5, 0) # decreasing time
1514

16-
xlabel('decreasing time (s)')
17-
ylabel('voltage (mV)')
18-
title('Should be growing...')
19-
grid(True)
15+
plt.xlabel('decreasing time (s)')
16+
plt.ylabel('voltage (mV)')
17+
plt.title('Should be growing...')
18+
plt.grid(True)
2019

21-
show()
20+
plt.show()
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
#!/usr/bin/env python
21
"""
32
Layer images above one another using alpha blending
43
"""
54
from __future__ import division
6-
from pylab import *
5+
import matplotlib.pyplot as plt
6+
import numpy as np
77

88

99
def func3(x, y):
10-
return (1 - x/2 + x**5 + y**3)*exp(-(x**2 + y**2))
10+
return (1 - x/2 + x**5 + y**3)*np.exp(-(x**2 + y**2))
1111

1212
# make these smaller to increase the resolution
1313
dx, dy = 0.05, 8000 0.05
1414

15-
x = arange(-3.0, 3.0, dx)
16-
y = arange(-3.0, 3.0, dy)
17-
X, Y = meshgrid(x, y)
15+
x = np.arange(-3.0, 3.0, dx)
16+
y = np.arange(-3.0, 3.0, dy)
17+
X, Y = np.meshgrid(x, y)
1818

1919
# when layering multiple images, the images need to have the same
2020
# extent. This does not mean they need to have the same shape, but
@@ -24,20 +24,19 @@ def func3(x, y):
2424
# interpolation edge effects
2525

2626

27-
xmin, xmax, ymin, ymax = amin(x), amax(x), amin(y), amax(y)
27+
xmin, xmax, ymin, ymax = np.amin(x), np.amax(x), np.amin(y), np.amax(y)
2828
extent = xmin, xmax, ymin, ymax
2929
fig = plt.figure(frameon=False)
3030

31-
Z1 = array(([0, 1]*4 + [1, 0]*4)*4)
31+
Z1 = np.array(([0, 1]*4 + [1, 0]*4)*4)
3232
Z1.shape = (8, 8) # chessboard
33-
im1 = imshow(Z1, cmap=cm.gray, interpolation='nearest',
34-
extent=extent)
35-
hold(True)
33+
im1 = plt.imshow(Z1, cmap=plt.cm.gray, interpolation='nearest',
34+
extent=extent)
35+
plt.hold(True)
3636

3737
Z2 = func3(X, Y)
3838

39-
im2 = imshow(Z2, cmap=cm.jet, alpha=.9, interpolation='bilinear',
40-
extent=extent)
41-
#axis([xmin, xmax, ymin, ymax])
39+
im2 = plt.imshow(Z2, cmap=plt.cm.jet, alpha=.9, interpolation='bilinear',
40+
extent=extent)
4241

43-
show()
42+
plt.show()

lib/matplotlib/artist.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import re
77
import warnings
88
import inspect
9+
import numpy as np
910
import matplotlib
1011
import matplotlib.cbook as cbook
1112
from matplotlib.cbook import mplDeprecation
@@ -988,7 +989,8 @@ def format_cursor_data(self, data):
988989
data[0]
989990
except (TypeError, IndexError):
990991
data = [data]
991-
return ', '.join('{:0.3g}'.format(item) for item in data)
992+
return ', '.join('{:0.3g}'.format(item) for item in data if
993+
isinstance(item, (np.floating, np.integer, int, float)))
992994

993995
@property
994996
def mouseover(self):

src/_backend_agg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void RendererAgg::restore_region(BufferRegion &region)
109109

110110
// Restore the part of the saved region with offsets
111111
void
112-
RendererAgg::restore_region(BufferRegion &region, int x, int y, int xx1, int yy1, int xx2, int yy2)
112+
RendererAgg::restore_region(BufferRegion &region, int xx1, int yy1, int xx2, int yy2, int x, int y )
113113
{
114114
if (region.get_data() == NULL) {
115115
throw "Cannot restore_region from NULL data";

src/_backend_agg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class RendererAgg
215215

216216
BufferRegion *copy_from_bbox(agg::rect_d in_rect);
217217
void restore_region(BufferRegion &reg);
218-
void restore_region(BufferRegion &region, int x, int y, int xx1, int yy1, int xx2, int yy2);
218+
void restore_region(BufferRegion &region, int xx1, int yy1, int xx2, int yy2, int x, int y);
219219

220220
unsigned int width, height;
221221
double dpi;

0 commit comments

Comments
 (0)
0