Skip to content

Commit 283abca

Browse files
committed
Merged 'main/master'
1 parent b8f2edc commit 283abca

File tree

1,189 files changed

+27362
-13954
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,189 files changed

+27362
-13954
lines changed

CHANGELOG

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2011-04-14 interpolation="nearest" always interpolate images. A new
2+
mode "none" is introduced for no interpolation - JJL
3+
4+
2011-04-03 Fixed broken pick interface to AsteriskCollection objects
5+
used by scatter. - EF
6+
17
2011-04-01 The plot directive Sphinx extension now supports all of the
28
features in the Numpy fork of that extension. These
39
include doctest formatting, an 'include-source' option, and

lib/matplotlib/axes.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -2036,11 +2036,11 @@ def set_axisbelow(self, b):
20362036
self._axisbelow = b
20372037

20382038
@docstring.dedent_interpd
2039-
def grid(self, b=None, which='major', **kwargs):
2039+
def grid(self, b=None, which='major', axis='xy', **kwargs):
20402040
"""
20412041
call signature::
20422042
2043-
grid(self, b=None, which='major', **kwargs)
2043+
grid(self, b=None, which='major', axis='xy', **kwargs)
20442044
20452045
Set the axes grids on or off; *b* is a boolean. (For MATLAB
20462046
compatibility, *b* may also be a string, 'on' or 'off'.)
@@ -2052,6 +2052,9 @@ def grid(self, b=None, which='major', **kwargs):
20522052
*which* can be 'major' (default), 'minor', or 'both' to control
20532053
whether major tick grids, minor tick grids, or both are affected.
20542054
2055+
*axis* can be 'xy' (default), 'x', or 'y' to control which
2056+
set of gridlines are drawn.
2057+
20552058
*kawrgs* are used to set the grid line properties, eg::
20562059
20572060
ax.grid(color='r', linestyle='-', linewidth=2)
@@ -2064,8 +2067,11 @@ def grid(self, b=None, which='major', **kwargs):
20642067
if len(kwargs):
20652068
b = True
20662069
b = _string_to_bool(b)
2067-
self.xaxis.grid(b, which=which, **kwargs)
2068-
self.yaxis.grid(b, which=which, **kwargs)
2070+
2071+
if axis == 'x' or axis == 'xy':
2072+
self.xaxis.grid(b, which=which, **kwargs)
2073+
if axis == 'y' or axis == 'xy':
2074+
self.yaxis.grid(b, which=which, **kwargs)
20692075

20702076
def ticklabel_format(self, **kwargs):
20712077
"""

lib/matplotlib/collections.py

+30-8
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def __init__(self,
9393
self.set_linewidth(linewidths)
9494
self.set_linestyle(linestyles)
9595
self.set_antialiased(antialiaseds)
96+
self.set_pickradius(pickradius)
9697
self.set_urls(urls)
9798

9899

@@ -109,7 +110,6 @@ def __init__(self,
109110
else:
110111
self._uniform_offsets = offsets
111112

112-
self._pickradius = pickradius
113113
self.update(kwargs)
114114
self._paths = None
115115

@@ -232,26 +232,48 @@ def draw(self, renderer):
232232
gc.restore()
233233
renderer.close_group(self.__class__.__name__)
234234

235+
def set_pickradius(self, pr):
236+
self._pickradius = pr
237+
238+
def get_pickradius(self):
239+
return self._pickradius
240+
235241
def contains(self, mouseevent):
236242
"""
237243
Test whether the mouse event occurred in the collection.
238244
239245
Returns True | False, ``dict(ind=itemlist)``, where every
240246
item in itemlist contains the event.
241247
"""
242-
if callable(self._contains): return self._contains(self,mouseevent)
243-
if not self.get_visible(): return False,{}
248+
if callable(self._contains):
249+
return self._contains(self,mouseevent)
250+
251+
if not self.get_visible():
252+
return False, {}
253+
254+
if self._picker is True: # the Boolean constant, not just nonzero or 1
255+
pickradius = self._pickradius
256+
else:
257+
try:
258+
pickradius = float(self._picker)
259+
except TypeError:
260+
# This should not happen if "contains" is called via
261+
# pick, the normal route; the check is here in case
262+
# it is called through some unanticipated route.
263+
warnings.warn(
264+
"Collection picker %s could not be converted to float"
265+
% self._picker)
266+
pickradius = self._pickradius
244267

245268
transform, transOffset, offsets, paths = self._prepare_points()
246269

247270
ind = mpath.point_in_path_collection(
248-
mouseevent.x, mouseevent.y, self._pickradius,
271+
mouseevent.x, mouseevent.y, pickradius,
249272
transform.frozen(), paths, self.get_transforms(),
250-
offsets, transOffset, len(self._facecolors)>0)
251-
return len(ind)>0,dict(ind=ind)
273+
offsets, transOffset, pickradius <= 0)
274+
275+
return len(ind)>0, dict(ind=ind)
252276

253-
def set_pickradius(self,pickradius): self.pickradius = 5
254-
def get_pickradius(self): return self.pickradius
255277

256278
def set_urls(self, urls):
257279
if urls is None:

lib/matplotlib/image.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class _AxesImageBase(martist.Artist, cm.ScalarMappable):
3131
zorder = 0
3232
# map interpolation strings to module constants
3333
_interpd = {
34+
'none' : _image.NEAREST, # fall back to nearest when not supported
3435
'nearest' : _image.NEAREST,
3536
'bilinear' : _image.BILINEAR,
3637
'bicubic' : _image.BICUBIC,
@@ -446,10 +447,15 @@ def set_interpolation(self, s):
446447
"""
447448
Set the interpolation method the image uses when resizing.
448449
450+
if None, use a value from rc setting. If 'none', the image is
451+
shown as is without interpolating. 'none' is only supported in
452+
agg, ps and pdf backends and will fall back to 'nearest' mode
453+
for other backends.
454+
449455
ACCEPTS: ['nearest' | 'bilinear' | 'bicubic' | 'spline16' |
450456
'spline36' | 'hanning' | 'hamming' | 'hermite' | 'kaiser' |
451457
'quadric' | 'catrom' | 'gaussian' | 'bessel' | 'mitchell' |
452-
'sinc' | 'lanczos' | ]
458+
'sinc' | 'lanczos' | 'none' |]
453459
454460
"""
455461
if s is None: s = rcParams['image.interpolation']
@@ -610,10 +616,13 @@ def _check_unsampled_image(self, renderer):
610616
"""
611617
return True if the image is better to be drawn unsampled.
612618
"""
613-
if renderer.option_scale_image() and self.get_interpolation() == "nearest":
614-
return True
615-
else:
616-
return False
619+
if self.get_interpolation() == "none":
620+
if renderer.option_scale_image():
621+
return True
622+
else:
623+
warnings.warn("The backend (%s) does not support interpolation='none'. The image will be interpolated with 'nearest` mode." % (str(type(renderer))))
624+
625+
return False
617626

618627
def set_extent(self, extent):
619628
"""

lib/matplotlib/pylab.py

+3
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,6 @@ def save(*args, **kwargs):
293293

294294
# don't let numpy's datetime hide stdlib
295295
import datetime
296+
297+
if sys.version_info > (2, 6, 0):
298+
bytes = __builtins__['bytes']

lib/matplotlib/pyplot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2645,8 +2645,8 @@ def cla():
26452645
# This function was autogenerated by boilerplate.py. Do not edit as
26462646
# changes will be lost
26472647
@docstring.copy_dedent(Axes.grid)
2648-
def grid(b=None, which='major', **kwargs):
2649-
ret = gca().grid(b, which, **kwargs)
2648+
def grid(b=None, which='major', axis='xy', **kwargs):
2649+
ret = gca().grid(b, which, axis, **kwargs)
26502650
draw_if_interactive()
26512651
return ret
26522652

lib/matplotlib/testing/decorators.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@ def compare_images_generator():
8888
for extension in extensions:
8989
orig_expected_fnames = [os.path.join(baseline_dir,fname) + '.' + extension for fname in baseline_images]
9090
expected_fnames = [os.path.join(result_dir,'expected-'+fname) + '.' + extension for fname in baseline_images]
91-
for src,dst in zip( orig_expected_fnames, expected_fnames ):
92-
shutil.copyfile(src,dst)
9391
actual_fnames = [os.path.join(result_dir, fname) + '.' + extension for fname in baseline_images]
94-
have_baseline_images = [os.path.exists(expected) for expected in expected_fnames]
92+
have_baseline_images = [os.path.exists(expected) for expected in orig_expected_fnames]
9593
have_baseline_image = np.all(have_baseline_images)
9694
is_comparable = extension in comparable_formats()
9795
if not is_comparable:
@@ -113,11 +111,12 @@ def decorated_compare_images():
113111
result = func() # actually call the test function
114112
finally:
115113
os.chdir(old_dir)
116-
for actual,expected in zip(actual_fnames,expected_fnames):
117-
if not os.path.exists(expected):
114+
for original, expected in zip(orig_expected_fnames, expected_fnames):
115+
if not os.path.exists(original):
118116
raise ImageComparisonFailure(
119-
'image does not exist: %s'%expected)
120-
117+
'image does not exist: %s'%original)
118+
shutil.copyfile(original, expected)
119+
for actual,expected in zip(actual_fnames,expected_fnames):
121120
# compare the images
122121
err = compare_images( expected, actual, tol,
123122
in_decorator=True )
Binary file not shown.
Loading

0 commit comments

Comments
 (0)