-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
PGF Backend: Support interpolation='none' #6792
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -508,30 +508,34 @@ def get_image_magnification(self): | |
""" | ||
return 1.0 | ||
|
||
def draw_image(self, gc, x, y, im, trans=None): | ||
def draw_image(self, gc, x, y, im, transform=None): | ||
""" | ||
Draw the image instance into the current axes; | ||
Draw an RGBA image. | ||
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explanation: It's not an "image instance", and the renderer does not have any notion of axes (as far as I can see). |
||
|
||
*gc* | ||
a GraphicsContext containing clipping information | ||
a :class:`GraphicsContextBase` instance with clipping information. | ||
|
||
*x* | ||
is the distance in pixels from the left hand side of the canvas. | ||
the distance in physical units (i.e., dots or pixels) from the left | ||
hand side of the canvas. | ||
|
||
*y* | ||
the distance from the origin. That is, if origin is | ||
upper, y is the distance from top. If origin is lower, y | ||
is the distance from bottom | ||
the distance in physical units (i.e., dots or pixels) from the | ||
bottom side of the canvas. | ||
|
||
*im* | ||
An NxMx4 array of RGBA pixels (of dtype uint8). | ||
|
||
*trans* | ||
If the concrete backend is written such that | ||
`option_scale_image` returns `True`, an affine | ||
transformation may also be passed to `draw_image`. The | ||
backend should apply the transformation to the image | ||
before applying the translation of `x` and `y`. | ||
*transform* | ||
If and only if the concrete backend is written such that | ||
:meth:`option_scale_image` returns ``True``, an affine | ||
transformation *may* be passed to :meth:`draw_image`. It takes the | ||
form of a :class:`~matplotlib.transforms.Affine2DBase` instance. | ||
The translation vector of the transformation is given in physical | ||
units (i.e., dots or pixels). Note that the transformation does not | ||
override `x` and `y`, and has to be applied *before* translating | ||
the result by `x` and `y` (this can be accomplished by adding `x` | ||
and `y` to the translation vector defined by `transform`). | ||
""" | ||
raise NotImplementedError | ||
|
||
|
@@ -544,8 +548,8 @@ def option_image_nocomposite(self): | |
|
||
def option_scale_image(self): | ||
""" | ||
override this method for renderers that support arbitrary | ||
scaling of image (most of the vector backend). | ||
override this method for renderers that support arbitrary affine | ||
transformations in :meth:`draw_image` (most vector backends). | ||
""" | ||
return False | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not change kwarg name, it is a (subtle) api break for anyone who is using
**dd
to pass in kwargs.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is that if anybody passes
trans=
as a kwarg, it is already broken:The base class is the only one calling it
trans
, which leaves a trap for anybody using**dd
to pass in the keyword arguments.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is fun.
attn @mdboom I am inclined to accept this change and an API change entry for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Let's fix this to be consistent (
transform
everywhere) and add a note inapi_changes.rst
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I see correctly, it's already covered by https://github.com/matplotlib/matplotlib/blob/master/doc/api/api_changes/2015-12-30_draw_image.rst -- if I added another note, there would be two API changes for
draw_image()
listed for matplotlib 2.0. So shall we just leave it at that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh, yeah there is an entry for it, but just amend it to note this particular issue, as it isn't obvious from the current item that there is this change as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, from the current item it isn't obvious at all what has changed:
Both sentences apply to my PR as well, which just changes the changed interface. Sorry, I'm not trying to be a nuisance, but I cannot come up with a way that explicitly mentions my change without sounding silly (and confusing).
Also note that the interface change in that note belongs to #5718, which added the
trans
keyword in the first place, in an attempt to document the interface already present in the subclasses:https://github.com/matplotlib/matplotlib/pull/5718/files#diff-504c288d675954e4e24de83a19242f4dR518
I'm just changing this to correctly call it
transform
, which has been used in subclasses even before #5718 was proposed: https://github.com/matplotlib/matplotlib/pull/5718/files#diff-2623790aa8493ba82ef737fe0e63274dL1601So this is not actually an API change. Nobody can have used
trans=
as a keyword argument, because it wouldn't have worked.Is this convincing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see your point about
trans
. So, you are merely correcting a mistake before it reaches a release. Point taken.