Skip to content

Commit 67eb32b

Browse files
authored
Merge branch 'master' into doc-figure
2 parents 83b11dd + 433afcf commit 67eb32b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+702
-319
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ result_images
8080

8181
# Nose/Pytest generated files #
8282
###############################
83+
.pytest_cache/
8384
.cache/
8485
.coverage
8586
.coverage.*

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ addons:
3737
- texlive-latex-extra
3838
- texlive-latex-recommended
3939
- texlive-xetex
40+
- texlive-luatex
4041

4142
env:
4243
global:

doc/faq/howto_faq.rst

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ Finally, the multipage pdf object has to be closed::
136136

137137
pp.close()
138138

139+
The same can be done using the pgf backend::
140+
141+
from matplotlib.backends.backend_pgf import PdfPages
142+
139143

140144
.. _howto-subplots-adjust:
141145

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Multipage PDF support for pgf backend
2+
-------------------------------------
3+
4+
The pgf backend now also supports multipage PDF files.
5+
6+
.. code-block:: python
7+
8+
from matplotlib.backends.backend_pgf import PdfPages
9+
import matplotlib.pyplot as plt
10+
11+
with PdfPages('multipage.pdf') as pdf:
12+
# page 1
13+
plt.plot([2, 1, 3])
14+
pdf.savefig()
15+
16+
# page 2
17+
plt.cla()
18+
plt.plot([3, 1, 2])
19+
pdf.savefig()

doc/users/whats_new.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ revision, see the :ref:`github-stats`.
1414
..
1515
For a release, add a new section after this, then comment out the include
1616
and toctree below by indenting them. Uncomment them after the release.
17-
.. include:: next_whats_new/README.rst
18-
.. toctree::
19-
:glob:
20-
:maxdepth: 1
17+
.. include:: next_whats_new/README.rst
18+
.. toctree::
19+
:glob:
20+
:maxdepth: 1
2121

22-
next_whats_new/*
22+
next_whats_new/*
2323

2424

2525
New in Matplotlib 2.2

examples/misc/multipage_pdf.py

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
66
This is a demo of creating a pdf file with several pages,
77
as well as adding metadata and annotations to pdf files.
8+
9+
If you want to use a multipage pdf file using LaTeX, you need
10+
to use `from matplotlib.backends.backend_pgf import PdfPages`.
11+
This version however does not support `attach_note`.
812
"""
913

1014
import datetime

lib/matplotlib/artist.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -1463,13 +1463,9 @@ def setp(obj, *args, **kwargs):
14631463
raise ValueError('The set args must be string, value pairs')
14641464

14651465
# put args into ordereddict to maintain order
1466-
funcvals = OrderedDict()
1467-
for i in range(0, len(args) - 1, 2):
1468-
funcvals[args[i]] = args[i + 1]
1469-
1470-
ret = [o.update(funcvals) for o in objs]
1471-
ret.extend([o.set(**kwargs) for o in objs])
1472-
return [x for x in cbook.flatten(ret)]
1466+
funcvals = OrderedDict((k, v) for k, v in zip(args[::2], args[1::2]))
1467+
ret = [o.update(funcvals) for o in objs] + [o.set(**kwargs) for o in objs]
1468+
return list(cbook.flatten(ret))
14731469

14741470

14751471
def kwdoc(a):

lib/matplotlib/axes/_axes.py

+24-22
Original file line numberDiff line numberDiff line change
@@ -2190,39 +2190,17 @@ def bar(self, *args, **kwargs):
21902190
adjust_xlim = True
21912191
x = 0
21922192

2193-
x, height, width, y, linewidth = np.broadcast_arrays(
2194-
# Make args iterable too.
2195-
np.atleast_1d(x), height, width, y, linewidth)
2196-
21972193
if orientation == 'vertical':
21982194
self._process_unit_info(xdata=x, ydata=height, kwargs=kwargs)
21992195
if log:
22002196
self.set_yscale('log', nonposy='clip')
2201-
2202-
tick_label_axis = self.xaxis
2203-
tick_label_position = x
22042197
elif orientation == 'horizontal':
22052198
self._process_unit_info(xdata=width, ydata=y, kwargs=kwargs)
22062199
if log:
22072200
self.set_xscale('log', nonposx='clip')
2208-
2209-
tick_label_axis = self.yaxis
2210-
tick_label_position = y
22112201
else:
22122202
raise ValueError('invalid orientation: %s' % orientation)
22132203

2214-
linewidth = itertools.cycle(np.atleast_1d(linewidth))
2215-
color = itertools.chain(itertools.cycle(mcolors.to_rgba_array(color)),
2216-
# Fallback if color == "none".
2217-
itertools.repeat([0, 0, 0, 0]))
2218-
if edgecolor is None:
2219-
edgecolor = itertools.repeat(None)
2220-
else:
2221-
edgecolor = itertools.chain(
2222-
itertools.cycle(mcolors.to_rgba_array(edgecolor)),
2223-
# Fallback if edgecolor == "none".
2224-
itertools.repeat([0, 0, 0, 0]))
2225-
22262204
# lets do some conversions now since some types cannot be
22272205
# subtracted uniformly
22282206
if self.xaxis is not None:
@@ -2237,6 +2215,30 @@ def bar(self, *args, **kwargs):
22372215
if yerr is not None:
22382216
yerr = self.convert_yunits(yerr)
22392217

2218+
x, height, width, y, linewidth = np.broadcast_arrays(
2219+
# Make args iterable too.
2220+
np.atleast_1d(x), height, width, y, linewidth)
2221+
2222+
# Now that units have been converted, set the tick locations.
2223+
if orientation == 'vertical':
2224+
tick_label_axis = self.xaxis
2225+
tick_label_position = x
2226+
elif orientation == 'horizontal':
2227+
tick_label_axis = self.yaxis
2228+
tick_label_position = y
2229+
2230+
linewidth = itertools.cycle(np.atleast_1d(linewidth))
2231+
color = itertools.chain(itertools.cycle(mcolors.to_rgba_array(color)),
2232+
# Fallback if color == "none".
2233+
itertools.repeat([0, 0, 0, 0]))
2234+
if edgecolor is None:
2235+
edgecolor = itertools.repeat(None)
2236+
else:
2237+
edgecolor = itertools.chain(
2238+
itertools.cycle(mcolors.to_rgba_array(edgecolor)),
2239+
# Fallback if edgecolor == "none".
2240+
itertools.repeat([0, 0, 0, 0]))
2241+
22402242
# We will now resolve the alignment and really have
22412243
# left, bottom, width, height vectors
22422244
if align == 'center':

lib/matplotlib/axes/_base.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -988,11 +988,8 @@ def _gen_axes_spines(self, locations=None, offset=0.0, units='inches'):
988988
Intended to be overridden by new projection types.
989989
990990
"""
991-
return OrderedDict([
992-
('left', mspines.Spine.linear_spine(self, 'left')),
993-
('right', mspines.Spine.linear_spine(self, 'right')),
994-
('bottom', mspines.Spine.linear_spine(self, 'bottom')),
995-
('top', mspines.Spine.linear_spine(self, 'top'))])
991+
return OrderedDict((side, mspines.Spine.linear_spine(self, side))
992+
for side in ['left', 'right', 'bottom', 'top'])
996993

997994
def cla(self):
998995
"""Clear the current axes."""

lib/matplotlib/axes/_subplots.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ def _make_twin_axes(self, *kl, **kwargs):
173173
"""
174174
from matplotlib.projections import process_projection_requirements
175175
if 'sharex' in kwargs and 'sharey' in kwargs:
176-
raise ValueError("Twinned Axes may share only one axis.")
176+
# The following line is added in v2.2 to avoid breaking Seaborn,
177+
# which currently uses this internal API.
178+
if kwargs["sharex"] is not self and kwargs["sharey"] is not self:
179+
raise ValueError("Twinned Axes may share only one axis.")
177180
kl = (self.get_subplotspec(),) + kl
178181
projection_class, kwargs, key = process_projection_requirements(
179182
self.figure, *kl, **kwargs)

lib/matplotlib/backends/_gtk3_compat.py

-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
Thus, to force usage of PGI when both bindings are installed, import it first.
1212
"""
1313

14-
from __future__ import (absolute_import, division, print_function,
15-
unicode_literals)
16-
17-
import six
18-
1914
import importlib
2015
import sys
2116

0 commit comments

Comments
 (0)