-
Notifications
You must be signed in to change notification settings - Fork 229
DOC: Add gallery example to show text formatting #3987
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 20 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
77330ce
Add code for text formatting gallery example
yvonnefroehlich 760d5fd
Remove execution permission
yvonnefroehlich 26f0c64
Follow code style
yvonnefroehlich 4c5d25b
Split code
yvonnefroehlich 33dc050
Add docs
yvonnefroehlich ec9a6a8
Fix typo
yvonnefroehlich 74933b1
Use line length
yvonnefroehlich b622a53
Mention legnd in docs
yvonnefroehlich 5a7d11f
Add comment
yvonnefroehlich 7b980b2
Fix typo in formular
yvonnefroehlich 45a74c9
Adjust figure dimensions
yvonnefroehlich 48d045e
Mention title in doc
yvonnefroehlich 084a036
Adjust figure dimensions and add comma
yvonnefroehlich 15b2b8e
Update docs
yvonnefroehlich 2462e99
Update docs
yvonnefroehlich a1ac875
Merge branch 'main' into add-gallery-textformat
yvonnefroehlich f693d35
Remove double white space
yvonnefroehlich 98cf164
Update docs
yvonnefroehlich 8513300
Merge branch 'main' into add-gallery-textformat
yvonnefroehlich 02bd41a
Merge branch 'main' into add-gallery-textformat
yvonnefroehlich cde3f5e
Write complete sentence
yvonnefroehlich c05aa65
Write only letters within the words in small caps
yvonnefroehlich 29086e8
Merge branch 'main' into add-gallery-textformat
yvonnefroehlich 404bf4d
TEST - exclude image in legend tutorial
yvonnefroehlich ab0d6c5
Revert "TEST - exclude image in legend tutorial"
yvonnefroehlich 3764dec
Fix line length
yvonnefroehlich c6d5f86
Adjust word
yvonnefroehlich 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
""" | ||
Text formatting | ||
=============== | ||
|
||
There are various options for formatting text contained in a plot, e.g., text added | ||
via :meth:`pygmt.Figure.text`, the plot title, labels of colorbars as well as | ||
Cartesian axes, and legend entries. It's also possible to change the font as well | ||
as its color and size only for specific characters of a longer text. The supported | ||
fonts are listed at :doc:`Supported Fonts </techref/fonts>`. For an complete | ||
overview see :doc:`Text Formatting </techref/text_formatting>`. | ||
""" | ||
|
||
# %% | ||
import pygmt | ||
|
||
fig = pygmt.Figure() | ||
fig.basemap(region=[-1, 1, -4, 4], projection="X4c/5c", frame=0) | ||
|
||
# Change font color for specific characters of the word "PyGMT" | ||
# blue for "P", yellow for "y", and red for "GMT" | ||
fig.text(x=0, y=3, text="@;63/124/173;P@;;@;255/212/59;y@;;@;238/86/52;GMT@;;") | ||
|
||
# Change font size and style for one single character, respectively | ||
fig.text(x=0, y=2, text="te@:15:x@::t tex@%Courier-Oblique%t@%%") | ||
|
||
# Use superscript | ||
fig.text(x=0, y=1, text="E = mc@+2@+") | ||
|
||
# Use subscripts and Greek letters | ||
fig.text(x=0, y=0, text="@~s@~@-ij@- = c@-ijkl@- @~e@~@-kl@-") | ||
|
||
# Combine two characters above each other | ||
fig.text(x=0, y=-1, text="@!_~") | ||
|
||
# Underline the text | ||
fig.text(x=0, y=-2, text="@_underlined text@_") | ||
|
||
# Use small caps | ||
fig.text(x=0, y=-3, text="@#text in small caps@#") | ||
yvonnefroehlich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
fig.show() |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.