Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f8e7dd0

Browse filesBrowse files
committed
Don't composite path-clipped image; forward suppressComposite as needed.
1 parent 303873f commit f8e7dd0
Copy full SHA for f8e7dd0

File tree

Expand file treeCollapse file tree

5 files changed

+21
-4
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+21
-4
lines changed
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``Figure.suppressComposite`` now also controls compositing of Axes images
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3087,7 +3087,8 @@ def draw(self, renderer=None, inframe=False):
30873087
a.draw(renderer)
30883088
renderer.stop_rasterizing()
30893089

3090-
mimage._draw_list_compositing_images(renderer, self, artists)
3090+
mimage._draw_list_compositing_images(
3091+
renderer, self, artists, self.figure.suppressComposite)
30913092

30923093
renderer.close_group('axes')
30933094
self.stale = False

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,7 +2094,8 @@ def draw(self, renderer):
20942094
try:
20952095
renderer.open_group('subfigure', gid=self.get_gid())
20962096
self.patch.draw(renderer)
2097-
mimage._draw_list_compositing_images(renderer, self, artists)
2097+
mimage._draw_list_compositing_images(
2098+
renderer, self, artists, self.figure.suppressComposite)
20982099
for sfig in self.subfigs:
20992100
sfig.draw(renderer)
21002101
renderer.close_group('subfigure')
@@ -2118,7 +2119,7 @@ class Figure(FigureBase):
21182119
The `.Rectangle` instance representing the figure background patch.
21192120
21202121
suppressComposite
2121-
For multiple figure images, the figure will make composite images
2122+
For multiple images, the figure will make composite images
21222123
depending on the renderer option_image_nocomposite function. If
21232124
*suppressComposite* is a boolean, this will override the renderer.
21242125
"""

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def flush_images():
150150

151151
for a in artists:
152152
if (isinstance(a, _ImageBase) and a.can_composite() and
153-
a.get_clip_on()):
153+
a.get_clip_on() and not a.get_clip_path()):
154154
image_group.append(a)
155155
else:
156156
flush_images()

‎lib/matplotlib/tests/test_image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_image.py
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from numpy.testing import assert_array_equal
1212
from PIL import Image
1313

14+
import matplotlib as mpl
1415
from matplotlib import (
1516
_api, colors, image as mimage, patches, pyplot as plt, style, rcParams)
1617
from matplotlib.image import (AxesImage, BboxImage, FigureImage,
@@ -506,6 +507,18 @@ def test_image_composite_alpha():
506507
ax.set_ylim([5, 0])
507508

508509

510+
@check_figures_equal(extensions=["pdf"])
511+
def test_clip_path_disables_compositing(fig_test, fig_ref):
512+
t = np.arange(9).reshape((3, 3))
513+
for fig in [fig_test, fig_ref]:
514+
ax = fig.add_subplot()
515+
ax.imshow(t, clip_path=(mpl.path.Path([(0, 0), (0, 1), (1, 0)]),
516+
ax.transData))
517+
ax.imshow(t, clip_path=(mpl.path.Path([(1, 1), (1, 2), (2, 1)]),
518+
ax.transData))
519+
fig_ref.suppressComposite = True
520+
521+
509522
@image_comparison(['rasterize_10dpi'],
510523
extensions=['pdf', 'svg'], remove_text=True, style='mpl20')
511524
def test_rasterize_dpi():

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.