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

Skip to content

Commit 8cbafae

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 6e50219 + af33de4 commit 8cbafae

9 files changed

Lines changed: 45 additions & 30 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Deprecations
2+
````````````
3+
4+
The ``dryrun`` parameter to the various ``FigureCanvasFoo.print_foo`` methods is deprecated.

examples/images_contours_and_fields/plot_streamplot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
A stream plot, or streamline plot, is used to display 2D vector fields. This
77
example shows a few features of the :meth:`~.axes.Axes.streamplot` function:
88
9-
* Varying the color along a streamline.
10-
* Varying the density of streamlines.
11-
* Varying the line width along a streamline.
12-
* Controlling the starting points of streamlines.
13-
* Streamlines skipping masked regions and NaN values.
9+
* Varying the color along a streamline.
10+
* Varying the density of streamlines.
11+
* Varying the line width along a streamline.
12+
* Controlling the starting points of streamlines.
13+
* Streamlines skipping masked regions and NaN values.
1414
"""
1515
import numpy as np
1616
import matplotlib.pyplot as plt

lib/matplotlib/backend_bases.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,27 @@ def __init__(self, name, canvas, key, x=0, y=0, guiEvent=None):
15281528
self.key = key
15291529

15301530

1531+
def _get_renderer(figure, print_method):
1532+
"""
1533+
Get the renderer that would be used to save a `~.Figure`, and cache it on
1534+
the figure.
1535+
"""
1536+
# This is implemented by triggering a draw, then immediately jumping out of
1537+
# Figure.draw() by raising an exception.
1538+
1539+
class Done(Exception):
1540+
pass
1541+
1542+
def _draw(renderer): raise Done(renderer)
1543+
1544+
with cbook._setattr_cm(figure, draw=_draw):
1545+
try:
1546+
print_method(io.BytesIO())
1547+
except Done as exc:
1548+
figure._cachedRenderer, = exc.args
1549+
return figure._cachedRenderer
1550+
1551+
15311552
class FigureCanvasBase(object):
15321553
"""
15331554
The canvas the figure renders into.
@@ -2038,20 +2059,11 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None,
20382059
bbox_inches = rcParams['savefig.bbox']
20392060

20402061
if bbox_inches:
2041-
# call adjust_bbox to save only the given area
20422062
if bbox_inches == "tight":
2043-
# When bbox_inches == "tight", it saves the figure twice.
2044-
# The first save command (to a BytesIO) is just to estimate
2045-
# the bounding box of the figure.
2046-
result = print_method(
2047-
io.BytesIO(),
2048-
dpi=dpi,
2049-
facecolor=facecolor,
2050-
edgecolor=edgecolor,
2051-
orientation=orientation,
2052-
dryrun=True,
2053-
**kwargs)
2054-
renderer = self.figure._cachedRenderer
2063+
renderer = _get_renderer(
2064+
self.figure,
2065+
functools.partial(
2066+
print_method, dpi=dpi, orientation=orientation))
20552067
bbox_artists = kwargs.pop("bbox_extra_artists", None)
20562068
bbox_inches = self.figure.get_tightbbox(renderer,
20572069
bbox_extra_artists=bbox_artists)
@@ -2061,6 +2073,7 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None,
20612073

20622074
bbox_inches = bbox_inches.padded(pad)
20632075

2076+
# call adjust_bbox to save only the given area
20642077
restore_bbox = tight_bbox.adjust_bbox(self.figure, bbox_inches,
20652078
canvas.fixed_dpi)
20662079

lib/matplotlib/backends/backend_agg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ def print_to_buffer(self):
544544
# print_figure(), and the latter ensures that `self.figure.dpi` already
545545
# matches the dpi kwarg (if any).
546546

547+
@cbook._delete_parameter("3.2", "dryrun")
547548
def print_jpg(self, filename_or_obj, *args, dryrun=False,
548549
pil_kwargs=None, **kwargs):
549550
"""
@@ -598,6 +599,7 @@ def print_jpg(self, filename_or_obj, *args, dryrun=False,
598599

599600
print_jpeg = print_jpg
600601

602+
@cbook._delete_parameter("3.2", "dryrun")
601603
def print_tif(self, filename_or_obj, *args, dryrun=False,
602604
pil_kwargs=None, **kwargs):
603605
buf, size = self.print_to_buffer()

lib/matplotlib/backends/backend_pgf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ class FigureCanvasPgf(FigureCanvasBase):
775775
def get_default_filetype(self):
776776
return 'pdf'
777777

778+
@cbook._delete_parameter("3.2", "dryrun")
778779
def _print_pgf_to_fh(self, fh, *args,
779780
dryrun=False, bbox_inches_restore=None, **kwargs):
780781
if dryrun:

lib/matplotlib/backends/backend_ps.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ def _print_ps(self, outfile, format, *args,
870870
orientation, isLandscape, papertype,
871871
**kwargs)
872872

873+
@cbook._delete_parameter("3.2", "dryrun")
873874
def _print_figure(
874875
self, outfile, format, dpi=72, facecolor='w', edgecolor='w',
875876
orientation='portrait', isLandscape=False, papertype=None,

lib/matplotlib/figure.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,8 @@ def text(self, x, y, s, fontdict=None, withdash=False, **kwargs):
18671867
"""
18681868
default = dict(transform=self.transFigure)
18691869

1870-
if withdash:
1870+
if (withdash
1871+
and withdash is not cbook.deprecation._deprecated_parameter):
18711872
text = TextWithDash(x=x, y=y, text=s)
18721873
else:
18731874
text = Text(x=x, y=y, text=s)

lib/matplotlib/table.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ def get_children(self):
459459

460460
def get_window_extent(self, renderer):
461461
"""Return the bounding box of the table in window coords."""
462+
self._update_positions(renderer)
462463
boxes = [cell.get_window_extent(renderer)
463464
for cell in self._cells.values()]
464465
return Bbox.union(boxes)

lib/matplotlib/textpath.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -312,18 +312,10 @@ def get_glyphs_tex(self, prop, s, glyph_map=None,
312312
font.set_size(self.FONT_SCALE, self.DPI)
313313
# See comments in _get_ps_font_and_encoding.
314314
if enc is not None:
315-
if glyph not in enc:
316-
_log.warning(
317-
"The glyph %d of font %s cannot be converted with "
318-
"the encoding; glyph may be wrong.",
319-
glyph, font.fname)
320-
font.load_char(glyph, flags=LOAD_TARGET_LIGHT)
321-
else:
322-
index = font.get_name_index(enc[glyph])
323-
font.load_glyph(index, flags=LOAD_TARGET_LIGHT)
315+
index = font.get_name_index(enc[glyph])
316+
font.load_glyph(index, flags=LOAD_TARGET_LIGHT)
324317
else:
325-
index = glyph
326-
font.load_char(index, flags=LOAD_TARGET_LIGHT)
318+
font.load_char(glyph, flags=LOAD_TARGET_LIGHT)
327319
glyph_map_new[char_id] = font.get_path()
328320

329321
glyph_ids.append(char_id)

0 commit comments

Comments
 (0)