-
Notifications
You must be signed in to change notification settings - Fork 228
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
Draft
yvonnefroehlich
wants to merge
13
commits into
main
Choose a base branch
from
add-gallery-textformat
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 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 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 to format text added to a plot as well as the title of the | ||||||
plot and labels of colorbars, Cartesian axes, and legend entries, including, | ||||||
superscripts, subscripts, underlining and small caps (for an overview see | ||||||
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.
Suggested change
|
||||||
(:doc:`Text Formatting </techref/text_formatting>`). 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>`. | ||||||
""" | ||||||
|
||||||
# %% | ||||||
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 a single character, respectively | ||||||
fig.text(x=0, y=2, text="te@:15:x@::t tex@%Courier-Oblique%t@%%") | ||||||
|
||||||
# Superscript | ||||||
fig.text(x=0, y=1, text="E = mc@+2@+") | ||||||
|
||||||
# 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@#") | ||||||
|
||||||
fig.show() |
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.
Maybe rephrase it to something like: