Skip to content

Commit 867b4bb

Browse files
authored
Figure.magnetic_rose: Let declination_label support string with whitespaces (#4422)
1 parent 1ac7e7c commit 867b4bb

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

pygmt/src/magnetic_rose.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,15 @@ def magnetic_rose( # noqa: PLR0913
110110

111111
position = _parse_position(position, default=Position("BL", cstype="inside"))
112112

113-
if declination_label is not None and declination is None:
114-
raise GMTParameterError(
115-
required="declination",
116-
reason="Required when 'declination_label' is set.",
117-
)
113+
if declination_label is not None:
114+
if declination is None:
115+
raise GMTParameterError(
116+
required="declination",
117+
reason="Required when 'declination_label' is set.",
118+
)
119+
# Upstream issue that declination label with spaces is not properly handled.
120+
if " " in declination_label:
121+
declination_label = declination_label.replace(" ", "\\040")
118122

119123
aliasdict = AliasSystem(
120124
F=Alias(box, name="box"),
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
outs:
2-
- md5: 78c53322b2514fbcd56483b793d47ebe
3-
size: 28831
2+
- md5: c39fb0511ea0a4b92d8d0202252d72ad
3+
size: 28825
44
hash: md5
55
path: test_magnetic_rose_complete.png

pygmt/tests/test_magnetic_rose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_magnetic_rose_complete():
3434
outer_pen="1p,red",
3535
inner_pen="1p,blue",
3636
declination=11.5,
37-
declination_label="11.5°E",
37+
declination_label="11.5 °E",
3838
)
3939
return fig
4040

0 commit comments

Comments
 (0)