Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1a0717a
Add content for reference and anchor points
yvonnefroehlich Aug 10, 2025
93346ea
Remove execution permission
yvonnefroehlich Aug 10, 2025
e0e84e9
Add docs
yvonnefroehlich Aug 13, 2025
cbbdf67
Use Unix LF line ending
yvonnefroehlich Aug 13, 2025
45584da
Merge branch 'main' into add-techref-points
yvonnefroehlich Aug 14, 2025
f1e6409
Merge branch 'main' into add-techref-points
yvonnefroehlich Aug 19, 2025
484dc0b
Merge branch 'main' into add-techref-points
yvonnefroehlich Aug 25, 2025
73f8744
Merge branch 'main' into add-techref-points
yvonnefroehlich Sep 2, 2025
048c44d
Merge branch 'main' into add-techref-points
yvonnefroehlich Sep 3, 2025
033e7d3
Link to justification code page
yvonnefroehlich Sep 3, 2025
57a0ed5
Add links to ref pages
yvonnefroehlich Sep 3, 2025
3232e8c
Use correct synthax for links
yvonnefroehlich Sep 3, 2025
854cf48
Adjust formulation
yvonnefroehlich Sep 3, 2025
b3151ec
Merge branch 'main' into add-techref-points
yvonnefroehlich Sep 8, 2025
9bda825
Merge branch 'main' into add-techref-points
yvonnefroehlich Sep 10, 2025
8807b34
Merge branch 'main' into add-techref-points
yvonnefroehlich Sep 12, 2025
baeab36
Merge branch 'main' into add-techref-points
yvonnefroehlich Sep 16, 2025
a674597
TEST: png to gif - will be removed
yvonnefroehlich Sep 16, 2025
a18c2fa
Change back to png
yvonnefroehlich Sep 16, 2025
146dae0
Use upper case letters in headings
yvonnefroehlich Sep 16, 2025
f6a94a5
Merge branch 'main' into add-techref-points
yvonnefroehlich Sep 17, 2025
0406740
Merge branch 'main' into add-techref-points
yvonnefroehlich Sep 20, 2025
e13fc61
Merge branch 'main' into add-techref-points
yvonnefroehlich Sep 24, 2025
041a402
Merge branch 'main' into add-techref-points
yvonnefroehlich Oct 2, 2025
7eea82a
TEST: No quotation marks for path variables
yvonnefroehlich Oct 2, 2025
4aba056
Revert "TEST: No quotation marks for path variables"
yvonnefroehlich Oct 2, 2025
8f23756
Merge branch 'main' into add-techref-points
yvonnefroehlich Oct 3, 2025
b69de9a
Merge branch 'main' into add-techref-points
yvonnefroehlich Oct 14, 2025
16ee983
Add list of parameters / aliases for modifiers
yvonnefroehlich Oct 15, 2025
8a25db0
Fix URL
yvonnefroehlich Oct 15, 2025
23a4afe
Remove remove example following the old codes
yvonnefroehlich Oct 15, 2025
4d25d5e
Remove GMT modifieres
yvonnefroehlich Oct 16, 2025
41f7570
Improve docs
yvonnefroehlich Oct 16, 2025
239bd66
Update docs for anchor_offset
yvonnefroehlich Oct 16, 2025
f60244b
Merge branch 'main' into add-techref-points
yvonnefroehlich Oct 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/techref/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ fonts.md
text_formatting.md
encodings.md
justification_codes.md
reference_anchor_points.md
environment_variables.md
```
9 changes: 5 additions & 4 deletions doc/techref/justification_codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ file_format: mystnb
# Justification Codes

To place plot embellishments, such as scalebars, directional roses, colorbars, legends,
text, or images on a figure, two points have to be specified: a point somewhere on the
figure (**reference point**) and a point on the feature (**anchor point**). For both,
users can use a two-character code, a combination of a vertical code and a horizontal
code (order-independent):
text, or images on a figure, two points have to be specified a point somewhere on the
figure (**reference point**) and a point on the feature (**anchor point**); for details
please see [Reference and anchor points](/techref/reference_anchor_points.md). For both,
users can use a two-character code, a combination of a vertical code and a horizontal code
(order-independent):

- Vertical: **T**(op), **M**(iddle), **B**(ottom)
- Horizontal: **L**(eft), **C**(entre), **R**(ight)
Expand Down
67 changes: 67 additions & 0 deletions doc/techref/reference_anchor_points.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
file_format: mystnb
---

# Reference and Anchor Points

For placing plot embellishments on a figure, we distinguish between two points: a point
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstrings in #4014 may be helpful.

somewhere on the figure (**reference point**) and a point on the feature (**anchor point**).
Four parameters are used to set and adjust these two points:

- `position`: a point somewhere on the figure corresponding to `position_type`.
- `position_type`: how to specify `position`. Choose between
- ``"inside"`` / ``"outside"``: inside / outside the plot bounding box using the [justification codes](/techref/reference_anchor_points.md),
- ``"mapcoords"``: map coordinates,
- ``"plotcoords"``: plot coordinates optionally with a unit,
- ``"boxcoords"``: normalized (0-1) coordinates corresponding to the bounding box.

- `anchor`: a point on the feature specified using the [justification codes](/techref/justification_codes.md).
- `anchor_offset`: offset the anchor point by *dx* and *dy* from the reference point.



```{code-cell}
---
tags: [remove-input]
---
"""
Script explaining reference and anchor points.
"""
import pygmt

size = 5
x1 = [-size, 0, size, size, size, 0, -size, -size, 0]
y1 = [-size, -size, -size, 0, size, size, size, 0, 0]
x2 = [-3, -2, -1, -1, -1, -2, -3, -3, -2]
y2 = [-1, -1, -1, 0, 1, 1, 1, 0, 0]
codes = ["BL", "BC", "BR", "MR", "TR", "TC", "TL", "ML", "MC"]

fig = pygmt.Figure()
fig.basemap(projection="X10c/6c", region=[-size, size, -size, size], frame=0)

fig.text(
text=codes,
x=x1,
y=y1,
justify=codes,
offset="j0.5c/0.2c+v1p,gray30",
font="10p,1,black",
)

fig.plot(x=x2[0:-1], y=y2[0:-1], fill="bisque")

fig.plot(x=-size, y=size, style="s0.6c", fill="lightred", no_clip=True)
fig.plot(x=x1, y=y1, style="c0.25c", fill="steelblue", no_clip=True)

fig.plot(x=-3, y=1, style="s0.6c", fill="orange")
fig.plot(x=x2, y=y2, style="c0.15c", fill="darkblue")

fig.plot(x=[-5, -3], y=[5, 1], pen="0.5p,black")
fig.plot(x=[-5, -3], y=[1, 1], pen="0.5p,black,2_2")
fig.plot(x=[-3, -3], y=[1, 5], pen="0.5p,black,2_2")

fig.text(x=-4, y=1, text="dx", offset="0c/0.2c")
fig.text(x=-3, y=3, text="dy", offset="-0.2c/0c")

fig.show(width=600)
```