Skip to content

Commit 98381ab

Browse files
authored
Merge pull request matplotlib#26500 from Tsufael/add-qt-interpolation_stage-selector-for-images
closes matplotlib#26477 ENH: Add interpolation_stage in qt figureoptions
2 parents 69a1a75 + 518d70f commit 98381ab

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ def prepare_data(d, init):
164164
mappabledata.append((
165165
'Interpolation',
166166
[mappable.get_interpolation(), *interpolations]))
167+
168+
interpolation_stages = ['data', 'rgba']
169+
mappabledata.append((
170+
'Interpolation stage',
171+
[mappable.get_interpolation_stage(), *interpolation_stages]))
172+
167173
mappables.append([mappabledata, label, ""])
168174
# Is there a scalarmappable displayed?
169175
has_sm = bool(mappables)
@@ -227,9 +233,11 @@ def apply_callback(data):
227233
# Set ScalarMappables.
228234
for index, mappable_settings in enumerate(mappables):
229235
mappable = labeled_mappables[index][1]
230-
if len(mappable_settings) == 5:
231-
label, cmap, low, high, interpolation = mappable_settings
236+
if len(mappable_settings) == 6:
237+
label, cmap, low, high, interpolation, interpolation_stage = \
238+
mappable_settings
232239
mappable.set_interpolation(interpolation)
240+
mappable.set_interpolation_stage(interpolation_stage)
233241
elif len(mappable_settings) == 4:
234242
label, cmap, low, high = mappable_settings
235243
mappable.set_label(label)

lib/matplotlib/image.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,14 @@ def set_interpolation(self, s):
773773
self._interpolation = s
774774
self.stale = True
775775

776+
def get_interpolation_stage(self):
777+
"""
778+
Return when interpolation happens during the transform to RGBA.
779+
780+
One of 'data', 'rgba'.
781+
"""
782+
return self._interpolation_stage
783+
776784
def set_interpolation_stage(self, s):
777785
"""
778786
Set when interpolation happens during the transform to RGBA.

lib/matplotlib/image.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class _ImageBase(martist.Artist, cm.ScalarMappable):
8989
def get_shape(self) -> tuple[int, int, int]: ...
9090
def get_interpolation(self) -> str: ...
9191
def set_interpolation(self, s: str | None) -> None: ...
92+
def get_interpolation_stage(self) -> Literal["data", "rgba"]: ...
9293
def set_interpolation_stage(self, s: Literal["data", "rgba"]) -> None: ...
9394
def can_composite(self) -> bool: ...
9495
def set_resample(self, v: bool | None) -> None: ...

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy