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

Skip to content

Commit 2982b85

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.x' into merge2xmaster2
2 parents 2b97396 + 5266fea commit 2982b85

8 files changed

Lines changed: 43 additions & 22 deletions

File tree

examples/text_labels_and_annotations/rainbow_text.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ def rainbow_text(x, y, strings, colors, ax=None, **kw):
4141

4242
# horizontal version
4343
for s, c in zip(strings, colors):
44-
text = ax.text(x, y, " " + s + " ", color=c, transform=t, **kw)
44+
text = ax.text(x, y, s + " ", color=c, transform=t, **kw)
4545
text.draw(canvas.get_renderer())
4646
ex = text.get_window_extent()
4747
t = transforms.offset_copy(text._transform, x=ex.width, units='dots')
4848

4949
# vertical version
5050
for s, c in zip(strings, colors):
51-
text = ax.text(x, y, " " + s + " ", color=c, transform=t,
51+
text = ax.text(x, y, s + " ", color=c, transform=t,
5252
rotation=90, va='bottom', ha='center', **kw)
5353
text.draw(canvas.get_renderer())
5454
ex = text.get_window_extent()
@@ -57,6 +57,6 @@ def rainbow_text(x, y, strings, colors, ax=None, **kw):
5757

5858
rainbow_text(0, 0, "all unicorns poop rainbows ! ! !".split(),
5959
['red', 'cyan', 'brown', 'green', 'blue', 'purple', 'black'],
60-
size=18)
60+
size=16)
6161

6262
plt.show()

lib/matplotlib/animation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,8 +858,8 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
858858
# Re-use the savefig DPI for ours if none is given
859859
if dpi is None:
860860
dpi = rcParams['savefig.dpi']
861-
if dpi == 'figure':
862-
dpi = self._fig.dpi
861+
if dpi == 'figure':
862+
dpi = self._fig.dpi
863863

864864
if codec is None:
865865
codec = rcParams['animation.codec']

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,8 +2141,8 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
21412141

21422142
if dpi is None:
21432143
dpi = rcParams['savefig.dpi']
2144-
if dpi == 'figure':
2145-
dpi = self.figure.dpi
2144+
if dpi == 'figure':
2145+
dpi = self.figure.dpi
21462146

21472147
origDPI = self.figure.dpi
21482148
origfacecolor = self.figure.get_facecolor()

lib/matplotlib/backends/backend_qt5agg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ def draw_idle(self):
172172
QtCore.QTimer.singleShot(0, self.__draw_idle_agg)
173173

174174
def __draw_idle_agg(self, *args):
175+
if self.height() < 0 or self.width() < 0:
176+
self._agg_draw_pending = False
177+
return
175178
try:
176179
FigureCanvasAgg.draw(self)
177180
self.update()

lib/matplotlib/backends/qt_compat.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,23 @@
4343

4444
QT_API = None
4545

46-
if (QT_API_ENV is not None):
46+
# check if any binding is already imported, if so silently ignore the
47+
# rcparams/ENV settings and use what ever is already imported.
48+
if 'PySide' in sys.modules:
49+
# user has imported PySide before importing mpl
50+
QT_API = QT_API_PYSIDE
51+
52+
if 'PyQt4' in sys.modules:
53+
# user has imported PyQt4 before importing mpl
54+
# this case also handles the PyQt4v2 case as once sip is imported
55+
# the API versions can not be changed so do not try
56+
QT_API = QT_API_PYQT
57+
58+
if 'PyQt5' in sys.modules:
59+
# the user has imported PyQt5 before importing mpl
60+
QT_API = QT_API_PYQT5
61+
62+
if (QT_API_ENV is not None) and QT_API is None:
4763
try:
4864
QT_ENV_MAJOR_VERSION = ETS[QT_API_ENV][1]
4965
except KeyError:
@@ -62,15 +78,12 @@
6278
elif rcParams['backend'] == 'Qt4Agg':
6379
QT_API = rcParams['backend.qt4']
6480
else:
65-
# A different backend was specified, but we still got here because a Qt
66-
# related file was imported. This is allowed, so lets try and guess
67-
# what we should be using.
68-
if "PyQt4" in sys.modules or "PySide" in sys.modules:
69-
# PyQt4 or PySide is actually used.
70-
QT_API = rcParams['backend.qt4']
71-
else:
72-
# This is a fallback: PyQt5 or PySide2
73-
QT_API = rcParams['backend.qt5']
81+
# A non-Qt backend was specified, no version of the Qt
82+
# bindings is imported, but we still got here because a Qt
83+
# related file was imported. This is allowed, fall back to Qt5
84+
# using which ever binding the rparams ask for.
85+
86+
QT_API = rcParams['backend.qt5']
7487

7588
# We will define an appropriate wrapper for the differing versions
7689
# of file dialog.

lib/matplotlib/figure.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,8 +1641,6 @@ def savefig(self, *args, **kwargs):
16411641
"""
16421642

16431643
kwargs.setdefault('dpi', rcParams['savefig.dpi'])
1644-
if kwargs['dpi'] == 'figure':
1645-
kwargs['dpi'] = self.get_dpi()
16461644
frameon = kwargs.pop('frameon', rcParams['savefig.frameon'])
16471645
transparent = kwargs.pop('transparent',
16481646
rcParams['savefig.transparent'])

lib/matplotlib/tests/test_colors.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
from nose.tools import assert_raises, assert_equal, assert_true
99
from nose.tools import assert_sequence_equal
1010

11+
try:
12+
# this is not available in nose + py2.6
13+
from nose.tools import assert_sequence_equal
14+
except ImportError:
15+
assert_sequence_equal = None
16+
1117
import numpy as np
1218
from numpy.testing.utils import assert_array_equal, assert_array_almost_equal
1319
from nose.plugins.skip import SkipTest
@@ -570,7 +576,8 @@ def test_pandas_iterable():
570576
import pandas as pd
571577
except ImportError:
572578
raise SkipTest("Pandas not installed")
573-
579+
if assert_sequence_equal is None:
580+
raise SkipTest("nose lacks required function")
574581
# Using a list or series yields equivalent
575582
# color maps, i.e the series isn't seen as
576583
# a single color

src/_image_resample.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,8 @@ void resample(
908908

909909
if (params.interpolation != NEAREST &&
910910
params.is_affine &&
911-
abs(params.affine.sx) == 1.0 &&
912-
abs(params.affine.sy) == 1.0 &&
911+
fabs(params.affine.sx) == 1.0 &&
912+
fabs(params.affine.sy) == 1.0 &&
913913
params.affine.shx == 0.0 &&
914914
params.affine.shy == 0.0) {
915915
params.interpolation = NEAREST;

0 commit comments

Comments
 (0)