Skip to content

Commit 1445ccd

Browse files
authored
Merge branch 'main' into dependabot/github_actions/CodSpeedHQ/action-4.0.0
2 parents d9cfdbd + c0403aa commit 1445ccd

File tree

12 files changed

+172
-45
lines changed

12 files changed

+172
-45
lines changed

.github/workflows/ci_tests.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
GH_TOKEN: ${{ github.token }}
152152

153153
- name: Install uv
154-
uses: astral-sh/setup-uv@4959332f0f014c5280e7eac8b70c90cb574c9f9b # v6.6.0
154+
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
155155
with:
156156
activate-environment: true
157157
python-version: ${{ matrix.python-version }}
@@ -163,7 +163,11 @@ jobs:
163163
164164
# Pull baseline image data from dvc remote (DAGsHub)
165165
- name: Pull baseline image data from dvc remote
166-
run: uv run dvc pull --no-run-cache --verbose && ls -lhR pygmt/tests/baseline/
166+
run: |
167+
uv run dvc remote modify upstream url https://${DAGSHUB_TOKEN}@dagshub.com/GenericMappingTools/pygmt.dvc --local
168+
uv run dvc pull --no-run-cache --verbose && ls -lhR pygmt/tests/baseline/
169+
env:
170+
DAGSHUB_TOKEN: ${{ secrets.DAGSHUB_TOKEN }}
167171

168172
# Install the package that we want to test
169173
- name: Install the package
@@ -183,7 +187,7 @@ jobs:
183187

184188
# Upload coverage to Codecov
185189
- name: Upload coverage to Codecov
186-
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
190+
uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0
187191
if: success() || failure()
188192
with:
189193
use_oidc: true

.github/workflows/ci_tests_dev.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ jobs:
161161

162162
# Pull baseline image data from dvc remote (DAGsHub)
163163
- name: Pull baseline image data from dvc remote
164-
run: dvc pull --no-run-cache --verbose && ls -lhR pygmt/tests/baseline/
164+
run: |
165+
dvc remote modify upstream url https://${DAGSHUB_TOKEN}@dagshub.com/GenericMappingTools/pygmt.dvc --local
166+
dvc pull --no-run-cache --verbose && ls -lhR pygmt/tests/baseline/
167+
env:
168+
DAGSHUB_TOKEN: ${{ secrets.DAGSHUB_TOKEN }}
165169

166170
# Download cached remote files (artifacts) from GitHub
167171
- name: Download remote data from GitHub

.github/workflows/dvc-diff.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ jobs:
5757
env:
5858
repo_token: ${{ github.token }}
5959
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
60+
DAGSHUB_TOKEN: ${{ secrets.DAGSHUB_TOKEN }}
6061
run: |
6162
echo -e "## Summary of changed images\n" > report.md
6263
echo -e "This is an auto-generated report of images that have changed on the DVC remote\n" >> report.md
6364
65+
# Configure DVC to use the DAGsHub remote via a token
66+
dvc remote modify upstream url https://${DAGSHUB_TOKEN}@dagshub.com/GenericMappingTools/pygmt.dvc --local
67+
6468
# Pull image data from cloud storage
6569
dvc pull --remote upstream
6670
dvc diff --md main HEAD >> report.md

.github/workflows/release-baseline-images.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ jobs:
3131
uses: iterative/setup-dvc@175771be1dc3d119268e00a896b52a4b77decb5e # v1.2.0
3232

3333
- name: Pull baseline image data from dvc remote
34-
run: dvc pull && ls -lhR pygmt/tests/baseline/
34+
run: |
35+
dvc remote modify upstream url https://${DAGSHUB_TOKEN}@dagshub.com/GenericMappingTools/pygmt.dvc --local
36+
dvc pull && ls -lhR pygmt/tests/baseline/
37+
env:
38+
DAGSHUB_TOKEN: ${{ secrets.DAGSHUB_TOKEN }}
3539

3640
- name: Create the baseline image asset in zip format
3741
run: |

doc/techref/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ fonts.md
1414
text_formatting.md
1515
patterns.md
1616
encodings.md
17+
justification_codes.md
1718
environment_variables.md
1819
```

doc/techref/justification_codes.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
file_format: mystnb
3+
---
4+
5+
# Justification codes
6+
7+
To place plot embellishments, such as scalebars, directional roses, colorbars, legends,
8+
text, or images on a figure, two points have to be specified: a point somewhere on the
9+
figure (**reference point**) and a point on the feature (**anchor point**). For both,
10+
users can use a two-character code, a combination of a vertical code and a horizontal
11+
code (order-independent):
12+
13+
- Vertical: **T**(op), **M**(iddle), **B**(ottom)
14+
- Horizontal: **L**(eft), **C**(entre), **R**(ight)
15+
16+
For example, `"TL"` means **T**op **L**eft.
17+
18+
The possible nine justification codes are visualized in the sketch below:
19+
20+
```{code-cell}
21+
---
22+
tags: [remove-input]
23+
---
24+
"""
25+
Script showing the justification codes used in GMT / PyGMT.
26+
"""
27+
import pygmt
28+
29+
size = 5
30+
x1 = [-size, 0, size, size, size, 0, -size, -size, 0]
31+
y1 = [-size, -size, -size, 0, size, size, size, 0, 0]
32+
codes = ["BL", "BC", "BR", "MR", "TR", "TC", "TL", "ML", "MC"]
33+
34+
fig = pygmt.Figure()
35+
fig.basemap(projection="X10c/6c", region=[-size, size, -size, size], frame=0)
36+
37+
fig.text(
38+
font="15p,1,black",
39+
x=x1,
40+
y=y1,
41+
text=codes,
42+
justify=codes,
43+
offset="j0.5c/0.5c+v2p,gray30",
44+
)
45+
46+
fig.plot(x=x1, y=y1, style="c0.3c", fill="steelblue", no_clip=True)
47+
48+
fig.text(
49+
font="15p",
50+
offset="j0.5c/0.5c",
51+
no_clip=True,
52+
x=[size, size, size, -size, 0, size],
53+
y=[size, 0, -size, size, size, size],
54+
justify=["ML", "ML", "ML", "BC", "BC", "BC"],
55+
text=[
56+
"@%1%T@%%op",
57+
"@%1%M@%%iddle",
58+
"@%1%B@%%ottom",
59+
"@%1%L@%%eft",
60+
"@%1%C@%%enter",
61+
"@%1%R@%%ight",
62+
],
63+
)
64+
65+
fig.show(width=600)
66+
```
67+
68+
For a non-rectangular geographic basemap, the justification codes refer to the invisible,
69+
rectangular map bounding box:
70+
71+
```{code-cell}
72+
---
73+
tags: [remove-input]
74+
---
75+
"""
76+
Script showing justification codes for non-rectangular geographic basemaps.
77+
"""
78+
fig = pygmt.Figure()
79+
fig.basemap(projection="H10c", region="g", frame=0)
80+
81+
for code in codes:
82+
fig.text(
83+
font="10p,1,black",
84+
position=code,
85+
justify=code,
86+
text=code,
87+
offset="j0.5c/0.5c+v2p,gray30",
88+
)
89+
fig.text(font="10p,steelblue", position=code, justify="MC", text="●", no_clip=True)
90+
91+
fig.show(width=600)
92+
```
93+
94+
95+
Plot embellishments can be abstracted as rectangles. Here, the justification codes are
96+
shown exemplary for a colorbar.
97+
98+
```{code-cell}
99+
---
100+
tags: [remove-input]
101+
---
102+
"""
103+
Script showing justification codes for plot embellishments, e.g., a colorbar.
104+
"""
105+
fig = pygmt.Figure()
106+
fig.basemap(projection="X10c/2c", region=[-size, size, -size, size], frame=0)
107+
108+
fig.colorbar(cmap="buda", frame=0, position="jMC+w10c/2c+h")
109+
110+
for code in codes:
111+
fig.text(
112+
font="10p,1,black",
113+
position=code,
114+
justify=code,
115+
text=code,
116+
offset="j0.3c/0.15c+v1p,gray30",
117+
)
118+
fig.plot(x=x1, y=y1, style="c0.2c", fill="steelblue", no_clip=True)
119+
120+
fig.show(width=600)
121+
```

examples/gallery/embellishments/colorbar.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
followed by the desired interval. The placement of the colorbar is set
1212
via the ``position`` parameter. There are the following options:
1313
14-
- **j/J**: placed inside/outside the plot bounding box using any 2-character
15-
combination of vertical (**T**\ op, **M**\ iddle, **B**\ ottom) and
16-
horizontal (**L**\ eft, **C**\ enter, **R**\ ight) alignment codes, e.g.
14+
- **j/J**: placed inside/outside the plot bounding box using a
15+
:doc:`2-character justification code </techref/justification_codes>`, e.g.,
1716
``position="jTR"`` for Top Right.
1817
- **g**: using map coordinates, e.g. ``position="g170/-45"`` for longitude
1918
170° East, latitude 45° South.

examples/gallery/embellishments/scalebar.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
of the reference point. Choose from
1111
1212
- **g**: Give map coordinates as *longitude*\/\ *latitude*.
13-
- **j**\|\ **J**: Specify a two-character (order independent) code.
14-
Choose from vertical **T**\(op), **M**\(iddle), or **B**\(ottom) and
15-
horizontal **L**\(eft), **C**\(entre), or **R**\(ight). Lower /
16-
uppercase **j** / **J** mean inside / outside of the map bounding
17-
box.
13+
- **j**\|\ **J**: Specify a
14+
:doc:`2-character justification code </techref/justification_codes>`.
15+
Lower / uppercase **j** / **J** mean inside / outside of the map
16+
bounding box.
1817
- **n**: Give normalized bounding box coordinates as *nx*\/\ *ny*.
1918
- **x**: Give plot coordinates as *x*\/\ *y*.
2019
@@ -26,9 +25,8 @@
2625
**+c** is appended the middle of the map is used. Note that *slon* is only
2726
optional for projections with constant scale along parallels, e.g.,
2827
Mercator projection.
29-
- justify: **+j**. Set the anchor point. Specify a two-character (order
30-
independent) code. Choose from vertical **T**\(op), **M**\(iddle), or
31-
**B**\(ottom) and horizontal **L**\(eft), **C**\(entre), or **R**\(ight).
28+
- justify: **+j**. Set the anchor point. Specify a
29+
:doc:`2-character justification code </techref/justification_codes>`.
3230
- offset: **+o**\ *offset* or **+o**\ *xoffset*/\ *yoffset*. Give either a
3331
common shift or individual shifts in x- (longitude) and y- (latitude)
3432
directions.

examples/tutorials/basics/text.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@
3737
# * ``angle``: Specifies the rotation of the text. It is measured counter-clockwise
3838
# from the horizontal in degrees.
3939
# * ``justify``: Defines the anchor point of the bounding box for the text. It is
40-
# specified by a two-letter (order independent) code, chosen from:
41-
#
42-
# * Vertical: **T**\(op), **M**\(iddle), **B**\(ottom)
43-
# * Horizontal: **L**\(eft), **C**\(entre), **R**\(ight)
44-
#
40+
# specified by a :doc:`2-character justification code </techref/justification_codes>`.
4541
# * ``offset``: Shifts the text relatively to the reference point.
4642

4743
fig = pygmt.Figure()
@@ -191,12 +187,8 @@
191187
#
192188
# Instead of using the ``x`` and ``y`` parameters, the ``position`` parameter can be
193189
# specified to set the reference point for the text on the plot. As for the ``justify``
194-
# parameter, the ``position`` parameter is specified by a two-letter (order independent)
195-
# code, chosen from:
196-
#
197-
# * Vertical: **T**\(op), **M**\(iddle), **B**\(ottom)
198-
# * Horizontal: **L**\(eft), **C**\(entre), **R**\(ight)
199-
#
190+
# parameter, the ``position`` parameter is specified by a
191+
# :doc:`2-character justification code </techref/justification_codes>`.
200192
# This can be helpful to add a tag to a subplot or text labels out of the plot or map
201193
# frame, e.g., for depth slices.
202194

pygmt/src/colorbar.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ def colorbar(
6868
[**+n**\ [*txt*]][**+o**\ *dx*\ [/*dy*]].
6969
Define the reference point on the map for the color scale using one of
7070
four coordinate systems: (1) Use **g** for map (user) coordinates, (2)
71-
use **j** or **J** for setting *refpoint* via a 2-character
72-
justification code that refers to the (invisible) map domain rectangle,
71+
use **j** or **J** for setting *refpoint* via a
72+
:doc:`2-character justification code </techref/justification_codes>`
73+
that refers to the (invisible) map domain rectangle,
7374
(3) use **n** for normalized (0-1) coordinates, or (4) use **x** for
7475
plot coordinates (inches, cm, etc.). All but **x** requires both
7576
``region`` and ``projection`` to be specified. Append **+w** followed
@@ -78,8 +79,9 @@ def colorbar(
7879
reverse the scale bar. Append **+h** to get a horizontal scale
7980
[Default is vertical (**+v**)]. By default, the anchor point on the
8081
scale is assumed to be the bottom left corner (**BL**), but this can
81-
be changed by appending **+j** followed by a 2-character
82-
justification code *justify*.
82+
be changed by appending **+j** followed by a
83+
:doc:`2-character justification code </techref/justification_codes>`
84+
*justify*.
8385
box : bool or str
8486
[**+c**\ *clearances*][**+g**\ *fill*][**+i**\ [[*gap*/]\ *pen*]]\
8587
[**+p**\ [*pen*]][**+r**\ [*radius*]][**+s**\ [[*dx*/*dy*/][*shade*]]].

0 commit comments

Comments
 (0)