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

Skip to content

Backports for 2.0.1 #7279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,13 @@ install:
pip install --upgrade setuptools
- |
# Install dependencies from pypi
pip install $PRE python-dateutil $NUMPY pyparsing!=2.1.6 $PANDAS pep8 cycler coveralls coverage
pip install $PRE python-dateutil $NUMPY pyparsing!=2.1.6 $PANDAS pep8 cycler coveralls coverage $MOCK
pip install $PRE -r doc-requirements.txt

# Install nose from a build which has partial
# support for python36 and suport for coverage output suppressing
pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose

# Install mock on python 2. Python 2.6 requires mock 1.0.1
# Since later versions have dropped support
- |
if [[ -n "$MOCK" ]]; then
echo $MOCK
pip install $MOCK
fi;
# We manually install humor sans using the package from Ubuntu 14.10. Unfortunatly humor sans is not
# availible in the Ubuntu version used by Travis but we can manually install the deb from a later
# version since is it basically just a .ttf file
Expand Down
5 changes: 5 additions & 0 deletions doc/users/whats_new/2015-11-05_hidpi.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Support for HiDPI (Retina) displays in the NbAgg and WebAgg backends
--------------------------------------------------------------------

The NbAgg and WebAgg backends will now use the full resolution of your
high-pixel-density display.
11 changes: 11 additions & 0 deletions doc/users/whats_new/boxplot_zorder_kwarg.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Boxplot Zorder Keyword Argument
-------------------------------

The ``zorder`` parameter now exists for :func:`boxplot`. This allows the zorder
of a boxplot to be set in the plotting function call.

Example
```````
::

boxplot(np.arange(10), zorder=10)
8 changes: 4 additions & 4 deletions examples/pie_and_polar_charts/polar_scatter_demo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Demo of scatter plot on a polar axis.

Size increases radially in this example and color increases with angle (just to
verify the symbols are being scattered correctly).
Size increases radially in this example and color increases with angle
(just to verify the symbols are being scattered correctly).
"""
import numpy as np
import matplotlib.pyplot as plt
Expand All @@ -11,11 +11,11 @@
N = 150
r = 2 * np.random.rand(N)
theta = 2 * np.pi * np.random.rand(N)
area = 200 * r**2 * np.random.rand(N)
area = 200 * r**2
colors = theta

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

plt.show()
32 changes: 19 additions & 13 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,14 @@ def tk_window_focus():
]


def verify_test_dependencies():
def _init_tests():
try:
import faulthandler
except ImportError:
pass
else:
faulthandler.enable()

if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
raise ImportError("matplotlib test data is not installed")

Expand Down Expand Up @@ -1563,37 +1570,36 @@ def verify_test_dependencies():
raise


def _get_extra_test_plugins():
from .testing.noseclasses import KnownFailure
from nose.plugins import attrib

return [KnownFailure, attrib.Plugin]


def test(verbosity=1):
"""run the matplotlib test suite"""
verify_test_dependencies()
try:
import faulthandler
except ImportError:
pass
else:
faulthandler.enable()
_init_tests()

old_backend = rcParams['backend']
try:
use('agg')
import nose
import nose.plugins.builtin
from .testing.noseclasses import KnownFailure
from nose.plugins.manager import PluginManager
from nose.plugins import multiprocess

# store the old values before overriding
plugins = []
plugins.append(KnownFailure())
plugins = _get_extra_test_plugins()
plugins.extend([plugin() for plugin in nose.plugins.builtin.plugins])

manager = PluginManager(plugins=plugins)
manager = PluginManager(plugins=[x() for x in plugins])
config = nose.config.Config(verbosity=verbosity, plugins=manager)

# Nose doesn't automatically instantiate all of the plugins in the
# child processes, so we have to provide the multiprocess plugin with
# a list.
multiprocess._instantiate_plugins = [KnownFailure]
multiprocess._instantiate_plugins = plugins

success = nose.run(
defaultTest=default_test_modules,
Expand Down
64 changes: 39 additions & 25 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1565,38 +1565,43 @@ def semilogx(self, *args, **kwargs):
"""
Make a plot with log scaling on the *x* axis.

Call signature::

semilogx(*args, **kwargs)

:func:`semilogx` supports all the keyword arguments of
:func:`~matplotlib.pyplot.plot` and
:meth:`matplotlib.axes.Axes.set_xscale`.

Notable keyword arguments:

*basex*: scalar > 1
Base of the *x* logarithm
Parameters
----------
basex : float, optional
Base of the *x* logarithm. The scalar should be larger
than 1.

*subsx*: [ *None* | sequence ]
subsx : array_like, optional
The location of the minor xticks; *None* defaults to
autosubs, which depend on the number of decades in the
plot; see :meth:`~matplotlib.axes.Axes.set_xscale` for
details.

*nonposx*: [ 'mask' | 'clip' ]
nonposx : string, optional, {'mask', 'clip'}
Non-positive values in *x* can be masked as
invalid, or clipped to a very small positive number
invalid, or clipped to a very small positive number.

The remaining valid kwargs are
Returns
-------
`~matplotlib.pyplot.plot`
Log-scaled plot on the *x* axis.

Other Parameters
----------------
:class:`~matplotlib.lines.Line2D` properties:

%(Line2D)s

.. seealso::
See Also
--------
loglog : For example code and figure.

Notes
-----
This function supports all the keyword arguments of
:func:`~matplotlib.pyplot.plot` and
:meth:`matplotlib.axes.Axes.set_xscale`.

:meth:`loglog`
For example code and figure
"""
if not self._hold:
self.cla()
Expand Down Expand Up @@ -3110,7 +3115,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
showbox=None, showfliers=None, boxprops=None,
labels=None, flierprops=None, medianprops=None,
meanprops=None, capprops=None, whiskerprops=None,
manage_xticks=True, autorange=False):
manage_xticks=True, autorange=False, zorder=None):
"""
Make a box and whisker plot.

Expand All @@ -3123,7 +3128,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
showbox=True, showfliers=True, boxprops=None,
labels=None, flierprops=None, medianprops=None,
meanprops=None, capprops=None, whiskerprops=None,
manage_xticks=True, autorange=False):
manage_xticks=True, autorange=False, zorder=None):

Make a box and whisker plot for each column of ``x`` or each
vector in sequence ``x``. The box extends from the lower to
Expand Down Expand Up @@ -3235,6 +3240,9 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
``shownotches`` is also True. Otherwise, means will be shown
as points.

zorder : scalar, optional (None)
Sets the zorder of the boxplot.

Other Parameters
----------------
showcaps : bool, optional (True)
Expand Down Expand Up @@ -3409,15 +3417,15 @@ def _update_dict(dictionary, rc_name, properties):
medianprops=medianprops, meanprops=meanprops,
meanline=meanline, showfliers=showfliers,
capprops=capprops, whiskerprops=whiskerprops,
manage_xticks=manage_xticks)
manage_xticks=manage_xticks, zorder=zorder)
return artists

def bxp(self, bxpstats, positions=None, widths=None, vert=True,
patch_artist=False, shownotches=False, showmeans=False,
showcaps=True, showbox=True, showfliers=True,
boxprops=None, whiskerprops=None, flierprops=None,
medianprops=None, capprops=None, meanprops=None,
meanline=False, manage_xticks=True):
meanline=False, manage_xticks=True, zorder=None):
"""
Drawing function for box and whisker plots.

Expand All @@ -3428,7 +3436,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
showcaps=True, showbox=True, showfliers=True,
boxprops=None, whiskerprops=None, flierprops=None,
medianprops=None, capprops=None, meanprops=None,
meanline=False, manage_xticks=True):
meanline=False, manage_xticks=True, zorder=None):

Make a box and whisker plot for each column of *x* or each
vector in sequence *x*. The box extends from the lower to
Expand Down Expand Up @@ -3532,6 +3540,9 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
manage_xticks : bool, default = True
If the function should adjust the xlim and xtick locations.

zorder : scalar, default = None
The zorder of the resulting boxplot

Returns
-------
result : dict
Expand Down Expand Up @@ -3574,7 +3585,10 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
# empty list of xticklabels
datalabels = []

zorder = mlines.Line2D.zorder
# Use default zorder if none specified
if zorder is None:
zorder = mlines.Line2D.zorder

zdelta = 0.1
# box properties
if patch_artist:
Expand Down
11 changes: 9 additions & 2 deletions lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from matplotlib.mathtext import MathTextParser
from matplotlib.path import Path
from matplotlib.transforms import Bbox, BboxBase
from matplotlib import colors as mcolors

from matplotlib.backends._backend_agg import RendererAgg as _RendererAgg
from matplotlib import _png
Expand Down Expand Up @@ -571,7 +572,6 @@ def print_to_buffer(self):
return result

if _has_pil:

# add JPEG support
def print_jpg(self, filename_or_obj, *args, **kwargs):
"""
Expand All @@ -593,14 +593,21 @@ def print_jpg(self, filename_or_obj, *args, **kwargs):
buf, size = self.print_to_buffer()
if kwargs.pop("dryrun", False):
return
# The image is "pasted" onto a white background image to safely
# handle any transparency
image = Image.frombuffer('RGBA', size, buf, 'raw', 'RGBA', 0, 1)
color = mcolors.colorConverter.to_rgb(
rcParams.get('savefig.facecolor', 'white'))
color = tuple([int(x * 255.0) for x in color])
background = Image.new('RGB', size, color)
background.paste(image, image)
options = restrict_dict(kwargs, ['quality', 'optimize',
'progressive'])

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

return image.save(filename_or_obj, format='jpeg', **options)
return background.save(filename_or_obj, format='jpeg', **options)
print_jpeg = print_jpg

# add TIFF support
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,9 @@ def createFontList(fontfiles, fontext='ttf'):
verbose.report("Cannot handle unicode filenames")
# print >> sys.stderr, 'Bad file is', fpath
continue
except IOError:
verbose.report("IO error - cannot open font file %s" % fpath)
continue
try:
prop = ttfFontProperty(font)
except (KeyError, RuntimeError, ValueError):
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2656,11 +2656,12 @@ def symbol(self, s, loc, toks):

# Do not space commas between brackets
if c == ',':
prev_char, next_char = '', ''
for i in six.moves.xrange(1, loc + 1):
prev_char = s[loc - i]
if prev_char != ' ':
break
for i in six.moves.xrange(1, loc + 1):
for i in six.moves.xrange(1, len(s) - loc):
next_char = s[loc + i]
if next_char != ' ':
break
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading