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

Skip to content

Commit fcace6c

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.0.x'
Conflicts: .travis.yml - kept extra lines from 2.0.x to print a few more diagnostics lib/matplotlib/tests/test_backend_pgf.py - keep master version of test decorators lib/matplotlib/tests/test_image.py - kept addational tests from 2.0.x - removed a @cleanup lib/matplotlib/tests/test_ticker.py - conflict from b03b71a kept master version Other: lib/matplotlib/tests/test_axes.py - remove @cleanup
2 parents f5b6246 + b6f17f3 commit fcace6c

17 files changed

+869
-47
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ before_install:
102102
fi
103103
104104
install:
105+
# Upgrade pip and setuptools. Mock has issues with the default version of
106+
# setuptools
105107
- |
106108
# Setup environment
107109
ccache -s
110+
git describe
108111
# Upgrade pip and setuptools and wheel to get as clean an install as possible
109112
pip install --upgrade pip
110113
pip install --upgrade wheel

doc/users/dflt_style_changes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ values is a single line of python
1818
See :ref:`customizing-with-matplotlibrc-files` for details about how to
1919
persistently and selectively revert many of these changes.
2020

21+
2122
.. contents:: Table of Contents
2223
:depth: 2
2324
:local:

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,6 +2829,9 @@ def errorbar(self, x, y, yerr=None, xerr=None,
28292829
fmt_style_kwargs = {k: v for k, v in
28302830
zip(('linestyle', 'marker', 'color'),
28312831
_process_plot_format(fmt)) if v is not None}
2832+
if fmt == 'none':
2833+
# Remove alpha=0 color that _process_plot_format returns
2834+
fmt_style_kwargs.pop('color')
28322835

28332836
if ('color' in kwargs or 'color' in fmt_style_kwargs or
28342837
ecolor is not None):

lib/matplotlib/axes/_base.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -718,10 +718,12 @@ def get_xaxis_text1_transform(self, pad_points):
718718
place axis elements in different locations.
719719
720720
"""
721+
labels_align = matplotlib.rcParams["xtick.alignment"]
722+
721723
return (self.get_xaxis_transform(which='tick1') +
722724
mtransforms.ScaledTranslation(0, -1 * pad_points / 72.0,
723725
self.figure.dpi_scale_trans),
724-
"top", "center")
726+
"top", labels_align)
725727

726728
def get_xaxis_text2_transform(self, pad_points):
727729
"""
@@ -744,10 +746,11 @@ def get_xaxis_text2_transform(self, pad_points):
744746
place axis elements in different locations.
745747
746748
"""
749+
labels_align = matplotlib.rcParams["xtick.alignment"]
747750
return (self.get_xaxis_transform(which='tick2') +
748751
mtransforms.ScaledTranslation(0, pad_points / 72.0,
749752
self.figure.dpi_scale_trans),
750-
"bottom", "center")
753+
"bottom", labels_align)
751754

752755
def get_yaxis_transform(self, which='grid'):
753756
"""
@@ -795,10 +798,11 @@ def get_yaxis_text1_transform(self, pad_points):
795798
place axis elements in different locations.
796799
797800
"""
801+
labels_align = matplotlib.rcParams["ytick.alignment"]
798802
return (self.get_yaxis_transform(which='tick1') +
799803
mtransforms.ScaledTranslation(-1 * pad_points / 72.0, 0,
800804
self.figure.dpi_scale_trans),
801-
"center_baseline", "right")
805+
labels_align, "right")
802806

803807
def get_yaxis_text2_transform(self, pad_points):
804808
"""
@@ -821,10 +825,12 @@ def get_yaxis_text2_transform(self, pad_points):
821825
place axis elements in different locations.
822826
823827
"""
828+
labels_align = matplotlib.rcParams["ytick.alignment"]
829+
824830
return (self.get_yaxis_transform(which='tick2') +
825831
mtransforms.ScaledTranslation(pad_points / 72.0, 0,
826832
self.figure.dpi_scale_trans),
827-
"center_baseline", "left")
833+
labels_align, "left")
828834

829835
def _update_transScale(self):
830836
self.transScale.set(
@@ -2541,13 +2547,10 @@ def ticklabel_format(self, **kwargs):
25412547
raise ValueError("scilimits must be a sequence of 2 integers")
25422548
if style[:3] == 'sci':
25432549
sb = True
2544-
elif style in ['plain', 'comma']:
2550+
elif style == 'plain':
25452551
sb = False
2546-
if style == 'plain':
2547-
cb = False
2548-
else:
2549-
cb = True
2550-
raise NotImplementedError("comma style remains to be added")
2552+
elif style == 'comma':
2553+
raise NotImplementedError("comma style remains to be added")
25512554
elif style == '':
25522555
sb = None
25532556
else:

lib/matplotlib/backends/backend_pgf.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,9 @@ def make_pdf_to_png_converter():
191191
# pick converter
192192
if "pdftocairo" in tools_available:
193193
def cairo_convert(pdffile, pngfile, dpi):
194-
cmd = [str("pdftocairo"), "-singlefile", "-png",
195-
"-r %d" % dpi, pdffile, os.path.splitext(pngfile)[0]]
196-
# for some reason this doesn't work without shell
197-
check_output(cmd, shell=True, stderr=subprocess.STDOUT)
194+
cmd = [str("pdftocairo"), "-singlefile", "-png", "-r", "%d" % dpi,
195+
pdffile, os.path.splitext(pngfile)[0]]
196+
check_output(cmd, stderr=subprocess.STDOUT)
198197
return cairo_convert
199198
elif "gs" in tools_available:
200199
def gs_convert(pdffile, pngfile, dpi):

lib/matplotlib/image.py

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,20 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
375375
# this is to work around spurious warnings coming
376376
# out of masked arrays.
377377
with np.errstate(invalid='ignore'):
378-
rgba[..., 1] = A < 0 # under data
379-
rgba[..., 2] = A > 1 # over data
380-
rgba[..., 3] = ~A.mask # bad data
378+
rgba[..., 1] = np.where(A < 0, np.nan, 1) # under data
379+
rgba[..., 2] = np.where(A > 1, np.nan, 1) # over data
380+
# Have to invert mask, Agg knows what alpha means
381+
# so if you put this in as 0 for 'good' points, they
382+
# all get zeroed out
383+
rgba[..., 3] = 1
384+
if A.mask.shape == A.shape:
385+
# this is the case of a nontrivial mask
386+
mask = np.where(A.mask, np.nan, 1)
387+
else:
388+
# this is the case that the mask is a
389+
# numpy.bool_ of False
390+
mask = A.mask
391+
# ~A.mask # masked data
381392
A = rgba
382393
output = np.zeros((out_height, out_width, 4),
383394
dtype=A.dtype)
@@ -418,12 +429,37 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
418429
# Convert back to a masked greyscale array so
419430
# colormapping works correctly
420431
hid_output = output
432+
# any pixel where the a masked pixel is included
433+
# in the kernel (pulling this down from 1) needs to
434+
# be masked in the output
435+
if len(mask.shape) == 2:
436+
out_mask = np.empty((out_height, out_width),
437+
dtype=mask.dtype)
438+
_image.resample(mask, out_mask, t,
439+
_interpd_[self.get_interpolation()],
440+
True, 1,
441+
self.get_filternorm() or 0.0,
442+
self.get_filterrad() or 0.0)
443+
out_mask = np.isnan(out_mask)
444+
else:
445+
out_mask = mask
446+
# we need to mask both pixels which came in as masked
447+
# and the pixels that Agg is telling us to ignore (relavent
448+
# to non-affine transforms)
449+
# Use half alpha as the threshold for pixels to mask.
450+
out_mask = out_mask | (hid_output[..., 3] < .5)
421451
output = np.ma.masked_array(
422-
hid_output[..., 0], hid_output[..., 3] < 0.5)
423-
# relabel under data
424-
output[hid_output[..., 1] > .5] = -1
452+
hid_output[..., 0],
453+
out_mask)
454+
# 'unshare' the mask array to
455+
# needed to suppress numpy warning
456+
del out_mask
457+
invalid_mask = ~output.mask * ~np.isnan(output.data)
458+
# relabel under data. If any of the input data for
459+
# the pixel has input out of the norm bounds,
460+
output[np.isnan(hid_output[..., 1]) * invalid_mask] = -1
425461
# relabel over data
426-
output[hid_output[..., 2] > .5] = 2
462+
output[np.isnan(hid_output[..., 2]) * invalid_mask] = 2
427463

428464
output = self.to_rgba(output, bytes=True, norm=False)
429465

0 commit comments

Comments
 (0)