diff --git a/examples/text_labels_and_annotations/rainbow_text.py b/examples/text_labels_and_annotations/rainbow_text.py index 9d83228c5b4..95142175ce3 100644 --- a/examples/text_labels_and_annotations/rainbow_text.py +++ b/examples/text_labels_and_annotations/rainbow_text.py @@ -41,14 +41,14 @@ def rainbow_text(x, y, strings, colors, ax=None, **kw): # horizontal version for s, c in zip(strings, colors): - text = ax.text(x, y, " " + s + " ", color=c, transform=t, **kw) + text = ax.text(x, y, s + " ", color=c, transform=t, **kw) text.draw(canvas.get_renderer()) ex = text.get_window_extent() t = transforms.offset_copy(text._transform, x=ex.width, units='dots') # vertical version for s, c in zip(strings, colors): - text = ax.text(x, y, " " + s + " ", color=c, transform=t, + text = ax.text(x, y, s + " ", color=c, transform=t, rotation=90, va='bottom', ha='center', **kw) text.draw(canvas.get_renderer()) ex = text.get_window_extent() @@ -57,6 +57,6 @@ def rainbow_text(x, y, strings, colors, ax=None, **kw): rainbow_text(0, 0, "all unicorns poop rainbows ! ! !".split(), ['red', 'cyan', 'brown', 'green', 'blue', 'purple', 'black'], - size=18) + size=16) plt.show() diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index d70c218c525..b74b1b5dd74 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -858,8 +858,8 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None, # Re-use the savefig DPI for ours if none is given if dpi is None: dpi = rcParams['savefig.dpi'] - if dpi == 'figure': - dpi = self._fig.dpi + if dpi == 'figure': + dpi = self._fig.dpi if codec is None: codec = rcParams['animation.codec'] diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 7475adc66bd..08b54b503b1 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2141,8 +2141,8 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w', if dpi is None: dpi = rcParams['savefig.dpi'] - if dpi == 'figure': - dpi = self.figure.dpi + if dpi == 'figure': + dpi = self.figure.dpi origDPI = self.figure.dpi origfacecolor = self.figure.get_facecolor() diff --git a/lib/matplotlib/backends/backend_qt5agg.py b/lib/matplotlib/backends/backend_qt5agg.py index 656c837e5e6..5920ab09c7c 100644 --- a/lib/matplotlib/backends/backend_qt5agg.py +++ b/lib/matplotlib/backends/backend_qt5agg.py @@ -172,6 +172,9 @@ def draw_idle(self): QtCore.QTimer.singleShot(0, self.__draw_idle_agg) def __draw_idle_agg(self, *args): + if self.height() < 0 or self.width() < 0: + self._agg_draw_pending = False + return try: FigureCanvasAgg.draw(self) self.update() diff --git a/lib/matplotlib/backends/qt_compat.py b/lib/matplotlib/backends/qt_compat.py index e30796537eb..728bd8ab7d0 100644 --- a/lib/matplotlib/backends/qt_compat.py +++ b/lib/matplotlib/backends/qt_compat.py @@ -43,7 +43,23 @@ QT_API = None -if (QT_API_ENV is not None): +# check if any binding is already imported, if so silently ignore the +# rcparams/ENV settings and use what ever is already imported. +if 'PySide' in sys.modules: + # user has imported PySide before importing mpl + QT_API = QT_API_PYSIDE + +if 'PyQt4' in sys.modules: + # user has imported PyQt4 before importing mpl + # this case also handles the PyQt4v2 case as once sip is imported + # the API versions can not be changed so do not try + QT_API = QT_API_PYQT + +if 'PyQt5' in sys.modules: + # the user has imported PyQt5 before importing mpl + QT_API = QT_API_PYQT5 + +if (QT_API_ENV is not None) and QT_API is None: try: QT_ENV_MAJOR_VERSION = ETS[QT_API_ENV][1] except KeyError: @@ -62,15 +78,12 @@ elif rcParams['backend'] == 'Qt4Agg': QT_API = rcParams['backend.qt4'] else: - # A different backend was specified, but we still got here because a Qt - # related file was imported. This is allowed, so lets try and guess - # what we should be using. - if "PyQt4" in sys.modules or "PySide" in sys.modules: - # PyQt4 or PySide is actually used. - QT_API = rcParams['backend.qt4'] - else: - # This is a fallback: PyQt5 or PySide2 - QT_API = rcParams['backend.qt5'] + # A non-Qt backend was specified, no version of the Qt + # bindings is imported, but we still got here because a Qt + # related file was imported. This is allowed, fall back to Qt5 + # using which ever binding the rparams ask for. + + QT_API = rcParams['backend.qt5'] # We will define an appropriate wrapper for the differing versions # of file dialog. diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 46560f65f15..d668763ee2d 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1641,8 +1641,6 @@ def savefig(self, *args, **kwargs): """ kwargs.setdefault('dpi', rcParams['savefig.dpi']) - if kwargs['dpi'] == 'figure': - kwargs['dpi'] = self.get_dpi() frameon = kwargs.pop('frameon', rcParams['savefig.frameon']) transparent = kwargs.pop('transparent', rcParams['savefig.transparent']) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index db14ad17bfb..de0200ebeaf 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -8,6 +8,12 @@ from nose.tools import assert_raises, assert_equal, assert_true from nose.tools import assert_sequence_equal +try: + # this is not available in nose + py2.6 + from nose.tools import assert_sequence_equal +except ImportError: + assert_sequence_equal = None + import numpy as np from numpy.testing.utils import assert_array_equal, assert_array_almost_equal from nose.plugins.skip import SkipTest @@ -570,7 +576,8 @@ def test_pandas_iterable(): import pandas as pd except ImportError: raise SkipTest("Pandas not installed") - + if assert_sequence_equal is None: + raise SkipTest("nose lacks required function") # Using a list or series yields equivalent # color maps, i.e the series isn't seen as # a single color diff --git a/src/_image_resample.h b/src/_image_resample.h index cee102244f2..86cbef03248 100644 --- a/src/_image_resample.h +++ b/src/_image_resample.h @@ -908,8 +908,8 @@ void resample( if (params.interpolation != NEAREST && params.is_affine && - abs(params.affine.sx) == 1.0 && - abs(params.affine.sy) == 1.0 && + fabs(params.affine.sx) == 1.0 && + fabs(params.affine.sy) == 1.0 && params.affine.shx == 0.0 && params.affine.shy == 0.0) { params.interpolation = NEAREST;