Figure.image: Add the parameter 'invert' for option -I#4089
Merged
Conversation
Comment on lines
+73
to
+75
| invert | ||
| Invert 1-bit image before plotting, i.e., black pixels (on) becomes white (off) | ||
| and vice versa. Ignored if used with color images. |
Member
There was a problem hiding this comment.
Hm, just trying this and maybe I am missing something here. I thought the remote raster image "vader1.png" is such a 1-bit image (see the last example at https://docs.generic-mapping-tools.org/dev/image.html#examples), but using I=True does not flip the black and white pixels as expected:
import pygmt
fig = pygmt.Figure()
fig.basemap(region=[-5, 5] * 2, projection="X3c/1c", frame=0)
fig.image(imagefile="@vader1.png", position="jLM")
fig.image(imagefile="@vader1.png", position="jMC", bitcolor=["gray+f", "blue+b"])
fig.image(imagefile="@vader1.png", position="jRM", I=True) # Does not do something
# fig.image(imagefile="@vader1.png", position="jRM", bitcolor=["black+f", "white+b"])
fig.show()
Same for
gmt image @vader1.png -I -png image_I_gmt
Member
Author
There was a problem hiding this comment.
Hmm, it looks like an upstream bug.
Member
There was a problem hiding this comment.
I tested it with the gmt dev version, and still no inverted colors. Thus, I wrote an issue report at GenericMappingTools/gmt#8795.
Member
Author
There was a problem hiding this comment.
The upstream bug has been fixed.
I've added a note in the docstrings.
196f51b to
40b3933
Compare
40b3933 to
22ac054
Compare
18 tasks
michaelgrund
approved these changes
Dec 17, 2025
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Alias
-Ioption toinvertand also sort parameters based on #4285.Upstream docs: https://docs.generic-mapping-tools.org/6.5/image.html#i
Preview: https://pygmt-dev--4089.org.readthedocs.build/en/4089/api/generated/pygmt.Figure.image.html
Related to #4263