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

Skip to content

Commit fdb3bac

Browse files
authored
Merge pull request #7279 from QuLogic/backports-2.0.1
Missed Backports for 2.0.1
2 parents 7e44d70 + f4152ce commit fdb3bac

29 files changed

+448
-304
lines changed

.travis.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,13 @@ install:
7777
pip install --upgrade setuptools
7878
- |
7979
# Install dependencies from pypi
80-
pip install $PRE python-dateutil $NUMPY pyparsing!=2.1.6 $PANDAS pep8 cycler coveralls coverage
80+
pip install $PRE python-dateutil $NUMPY pyparsing!=2.1.6 $PANDAS pep8 cycler coveralls coverage $MOCK
8181
pip install $PRE -r doc-requirements.txt
8282
8383
# Install nose from a build which has partial
8484
# support for python36 and suport for coverage output suppressing
8585
pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose
8686
87-
# Install mock on python 2. Python 2.6 requires mock 1.0.1
88-
# Since later versions have dropped support
89-
- |
90-
if [[ -n "$MOCK" ]]; then
91-
echo $MOCK
92-
pip install $MOCK
93-
fi;
9487
# We manually install humor sans using the package from Ubuntu 14.10. Unfortunatly humor sans is not
9588
# availible in the Ubuntu version used by Travis but we can manually install the deb from a later
9689
# version since is it basically just a .ttf file
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Support for HiDPI (Retina) displays in the NbAgg and WebAgg backends
2+
--------------------------------------------------------------------
3+
4+
The NbAgg and WebAgg backends will now use the full resolution of your
5+
high-pixel-density display.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Boxplot Zorder Keyword Argument
2+
-------------------------------
3+
4+
The ``zorder`` parameter now exists for :func:`boxplot`. This allows the zorder
5+
of a boxplot to be set in the plotting function call.
6+
7+
Example
8+
```````
9+
::
10+
11+
boxplot(np.arange(10), zorder=10)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
22
Demo of scatter plot on a polar axis.
33
4-
Size increases radially in this example and color increases with angle (just to
5-
verify the symbols are being scattered correctly).
4+
Size increases radially in this example and color increases with angle
5+
(just to verify the symbols are being scattered correctly).
66
"""
77
import numpy as np
88
import matplotlib.pyplot as plt
@@ -11,11 +11,11 @@
1111
N = 150
1212
r = 2 * np.random.rand(N)
1313
theta = 2 * np.pi * np.random.rand(N)
14-
area = 200 * r**2 * np.random.rand(N)
14+
area = 200 * r**2
1515
colors = theta
1616

1717
ax = plt.subplot(111, projection='polar')
18-
c = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.hsv)
18+
c = ax.scatter(theta, r, c=colors, s=area, cmap=plt.cm.hsv)
1919
c.set_alpha(0.75)
2020

2121
plt.show()

lib/matplotlib/__init__.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,14 @@ def tk_window_focus():
15281528
]
15291529

15301530

1531-
def verify_test_dependencies():
1531+
def _init_tests():
1532+
try:
1533+
import faulthandler
1534+
except ImportError:
1535+
pass
1536+
else:
1537+
faulthandler.enable()
1538+
15321539
if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
15331540
raise ImportError("matplotlib test data is not installed")
15341541

@@ -1563,37 +1570,36 @@ def verify_test_dependencies():
15631570
raise
15641571

15651572

1573+
def _get_extra_test_plugins():
1574+
from .testing.noseclasses import KnownFailure
1575+
from nose.plugins import attrib
1576+
1577+
return [KnownFailure, attrib.Plugin]
1578+
1579+
15661580
def test(verbosity=1):
15671581
"""run the matplotlib test suite"""
1568-
verify_test_dependencies()
1569-
try:
1570-
import faulthandler
1571-
except ImportError:
1572-
pass
1573-
else:
1574-
faulthandler.enable()
1582+
_init_tests()
15751583

15761584
old_backend = rcParams['backend']
15771585
try:
15781586
use('agg')
15791587
import nose
15801588
import nose.plugins.builtin
1581-
from .testing.noseclasses import KnownFailure
15821589
from nose.plugins.manager import PluginManager
15831590
from nose.plugins import multiprocess
15841591

15851592
# store the old values before overriding
1586-
plugins = []
1587-
plugins.append(KnownFailure())
1593+
plugins = _get_extra_test_plugins()
15881594
plugins.extend([plugin() for plugin in nose.plugins.builtin.plugins])
15891595

1590-
manager = PluginManager(plugins=plugins)
1596+
manager = PluginManager(plugins=[x() for x in plugins])
15911597
config = nose.config.Config(verbosity=verbosity, plugins=manager)
15921598

15931599
# Nose doesn't automatically instantiate all of the plugins in the
15941600
# child processes, so we have to provide the multiprocess plugin with
15951601
# a list.
1596-
multiprocess._instantiate_plugins = [KnownFailure]
1602+
multiprocess._instantiate_plugins = plugins
15971603

15981604
success = nose.run(
15991605
defaultTest=default_test_modules,

lib/matplotlib/axes/_axes.py

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,38 +1565,43 @@ def semilogx(self, *args, **kwargs):
15651565
"""
15661566
Make a plot with log scaling on the *x* axis.
15671567
1568-
Call signature::
1569-
1570-
semilogx(*args, **kwargs)
1571-
1572-
:func:`semilogx` supports all the keyword arguments of
1573-
:func:`~matplotlib.pyplot.plot` and
1574-
:meth:`matplotlib.axes.Axes.set_xscale`.
1575-
1576-
Notable keyword arguments:
1577-
1578-
*basex*: scalar > 1
1579-
Base of the *x* logarithm
1568+
Parameters
1569+
----------
1570+
basex : float, optional
1571+
Base of the *x* logarithm. The scalar should be larger
1572+
than 1.
15801573
1581-
*subsx*: [ *None* | sequence ]
1574+
subsx : array_like, optional
15821575
The location of the minor xticks; *None* defaults to
15831576
autosubs, which depend on the number of decades in the
15841577
plot; see :meth:`~matplotlib.axes.Axes.set_xscale` for
15851578
details.
15861579
1587-
*nonposx*: [ 'mask' | 'clip' ]
1580+
nonposx : string, optional, {'mask', 'clip'}
15881581
Non-positive values in *x* can be masked as
1589-
invalid, or clipped to a very small positive number
1582+
invalid, or clipped to a very small positive number.
15901583
1591-
The remaining valid kwargs are
1584+
Returns
1585+
-------
1586+
`~matplotlib.pyplot.plot`
1587+
Log-scaled plot on the *x* axis.
1588+
1589+
Other Parameters
1590+
----------------
15921591
:class:`~matplotlib.lines.Line2D` properties:
15931592
15941593
%(Line2D)s
15951594
1596-
.. seealso::
1595+
See Also
1596+
--------
1597+
loglog : For example code and figure.
1598+
1599+
Notes
1600+
-----
1601+
This function supports all the keyword arguments of
1602+
:func:`~matplotlib.pyplot.plot` and
1603+
:meth:`matplotlib.axes.Axes.set_xscale`.
15971604
1598-
:meth:`loglog`
1599-
For example code and figure
16001605
"""
16011606
if not self._hold:
16021607
self.cla()
@@ -3110,7 +3115,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
31103115
showbox=None, showfliers=None, boxprops=None,
31113116
labels=None, flierprops=None, medianprops=None,
31123117
meanprops=None, capprops=None, whiskerprops=None,
3113-
manage_xticks=True, autorange=False):
3118+
manage_xticks=True, autorange=False, zorder=None):
31143119
"""
31153120
Make a box and whisker plot.
31163121
@@ -3123,7 +3128,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
31233128
showbox=True, showfliers=True, boxprops=None,
31243129
labels=None, flierprops=None, medianprops=None,
31253130
meanprops=None, capprops=None, whiskerprops=None,
3126-
manage_xticks=True, autorange=False):
3131+
manage_xticks=True, autorange=False, zorder=None):
31273132
31283133
Make a box and whisker plot for each column of ``x`` or each
31293134
vector in sequence ``x``. The box extends from the lower to
@@ -3235,6 +3240,9 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
32353240
``shownotches`` is also True. Otherwise, means will be shown
32363241
as points.
32373242
3243+
zorder : scalar, optional (None)
3244+
Sets the zorder of the boxplot.
3245+
32383246
Other Parameters
32393247
----------------
32403248
showcaps : bool, optional (True)
@@ -3409,15 +3417,15 @@ def _update_dict(dictionary, rc_name, properties):
34093417
medianprops=medianprops, meanprops=meanprops,
34103418
meanline=meanline, showfliers=showfliers,
34113419
capprops=capprops, whiskerprops=whiskerprops,
3412-
manage_xticks=manage_xticks)
3420+
manage_xticks=manage_xticks, zorder=zorder)
34133421
return artists
34143422

34153423
def bxp(self, bxpstats, positions=None, widths=None, vert=True,
34163424
patch_artist=False, shownotches=False, showmeans=False,
34173425
showcaps=True, showbox=True, showfliers=True,
34183426
boxprops=None, whiskerprops=None, flierprops=None,
34193427
medianprops=None, capprops=None, meanprops=None,
3420-
meanline=False, manage_xticks=True):
3428+
meanline=False, manage_xticks=True, zorder=None):
34213429
"""
34223430
Drawing function for box and whisker plots.
34233431
@@ -3428,7 +3436,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
34283436
showcaps=True, showbox=True, showfliers=True,
34293437
boxprops=None, whiskerprops=None, flierprops=None,
34303438
medianprops=None, capprops=None, meanprops=None,
3431-
meanline=False, manage_xticks=True):
3439+
meanline=False, manage_xticks=True, zorder=None):
34323440
34333441
Make a box and whisker plot for each column of *x* or each
34343442
vector in sequence *x*. The box extends from the lower to
@@ -3532,6 +3540,9 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35323540
manage_xticks : bool, default = True
35333541
If the function should adjust the xlim and xtick locations.
35343542
3543+
zorder : scalar, default = None
3544+
The zorder of the resulting boxplot
3545+
35353546
Returns
35363547
-------
35373548
result : dict
@@ -3574,7 +3585,10 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35743585
# empty list of xticklabels
35753586
datalabels = []
35763587

3577-
zorder = mlines.Line2D.zorder
3588+
# Use default zorder if none specified
3589+
if zorder is None:
3590+
zorder = mlines.Line2D.zorder
3591+
35783592
zdelta = 0.1
35793593
# box properties
35803594
if patch_artist:

lib/matplotlib/backends/backend_agg.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from matplotlib.mathtext import MathTextParser
3939
from matplotlib.path import Path
4040
from matplotlib.transforms import Bbox, BboxBase
41+
from matplotlib import colors as mcolors
4142

4243
from matplotlib.backends._backend_agg import RendererAgg as _RendererAgg
4344
from matplotlib import _png
@@ -571,7 +572,6 @@ def print_to_buffer(self):
571572
return result
572573

573574
if _has_pil:
574-
575575
# add JPEG support
576576
def print_jpg(self, filename_or_obj, *args, **kwargs):
577577
"""
@@ -593,14 +593,21 @@ def print_jpg(self, filename_or_obj, *args, **kwargs):
593593
buf, size = self.print_to_buffer()
594594
if kwargs.pop("dryrun", False):
595595
return
596+
# The image is "pasted" onto a white background image to safely
597+
# handle any transparency
596598
image = Image.frombuffer('RGBA', size, buf, 'raw', 'RGBA', 0, 1)
599+
color = mcolors.colorConverter.to_rgb(
600+
rcParams.get('savefig.facecolor', 'white'))
601+
color = tuple([int(x * 255.0) for x in color])
602+
background = Image.new('RGB', size, color)
603+
background.paste(image, image)
597604
options = restrict_dict(kwargs, ['quality', 'optimize',
598605
'progressive'])
599606

600607
if 'quality' not in options:
601608
options['quality'] = rcParams['savefig.jpeg_quality']
602609

603-
return image.save(filename_or_obj, format='jpeg', **options)
610+
return background.save(filename_or_obj, format='jpeg', **options)
604611
print_jpeg = print_jpg
605612

606613
# add TIFF support

lib/matplotlib/font_manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,9 @@ def createFontList(fontfiles, fontext='ttf'):
594594
verbose.report("Cannot handle unicode filenames")
595595
# print >> sys.stderr, 'Bad file is', fpath
596596
continue
597+
except IOError:
598+
verbose.report("IO error - cannot open font file %s" % fpath)
599+
continue
597600
try:
598601
prop = ttfFontProperty(font)
599602
except (KeyError, RuntimeError, ValueError):

lib/matplotlib/mathtext.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2656,11 +2656,12 @@ def symbol(self, s, loc, toks):
26562656

26572657
# Do not space commas between brackets
26582658
if c == ',':
2659+
prev_char, next_char = '', ''
26592660
for i in six.moves.xrange(1, loc + 1):
26602661
prev_char = s[loc - i]
26612662
if prev_char != ' ':
26622663
break
2663-
for i in six.moves.xrange(1, loc + 1):
2664+
for i in six.moves.xrange(1, len(s) - loc):
26642665
next_char = s[loc + i]
26652666
if next_char != ' ':
26662667
break
Binary file not shown.

0 commit comments

Comments
 (0)