Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion examples/gallery/embellishments/directional_roses.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
====================

The :meth:`pygmt.Figure.directional_rose` method allows to add directional roses on
maps. Using the method without any arguments will plot a rose at the bottom left corner,
maps. Using the method without any arguments will plot a rose at the Top Right corner,
but this example will focus on customizing its position and appearance.

Colors of the map roses can be adjusted using :gmt-term:`MAP_DEFAULT_PEN` and
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/embellishments/magnetic_rose.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
fig.basemap(region=[-8, 8, -7, 7], projection="M10c", frame=True)

# Add a magnetic rose
# By default, it's placed in the lower left corner
# By default, it's placed in the Top Right corner
Comment thread
seisman marked this conversation as resolved.
fig.magnetic_rose()

# Add a magnetic rose with several adjustments
Expand Down
15 changes: 12 additions & 3 deletions pygmt/src/directional_rose.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
from collections.abc import Sequence
from typing import Literal

from packaging.version import Version
from pygmt._typing import AnchorCode
from pygmt.alias import Alias, AliasSystem
from pygmt.clib import Session
from pygmt.clib import Session, __gmt_version__
from pygmt.helpers import build_arg_list, fmt_docstring
from pygmt.params import Box, Position
from pygmt.src._common import _parse_position
Expand Down Expand Up @@ -45,7 +46,7 @@ def directional_rose(
- A :doc:`2-character justification code </techref/justification_codes>` for a
position inside the plot, e.g., ``"TL"`` for Top Left corner inside the plot.

If not specified, defaults to the Bottom Left corner of the plot.
If not specified, defaults to the Top Right corner of the plot.
width
Width of the rose in plot coordinates, or append unit ``%`` for a size in
percentage of plot width [Default is 10%].
Expand Down Expand Up @@ -83,7 +84,15 @@ def directional_rose(
"""
self._activate_figure()

position = _parse_position(position, default=Position("BL", cstype="inside"))
# The default position is set to "TR" since GMT 6.7.0, which has no default value
# in GMT 6.6.0 and earlier versions.
# TODO(GMT>6.6.0): Set 'default=None' after GMT 6.7.0.
position = _parse_position(
position,
default=None
if Version(__gmt_version__) > Version("6.6.0")
else Position("TR", cstype="inside"),
)

aliasdict = AliasSystem(
F=Alias(box, name="box"),
Expand Down
16 changes: 12 additions & 4 deletions pygmt/src/magnetic_rose.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
from collections.abc import Sequence
from typing import Literal

from packaging.version import Version
from pygmt._typing import AnchorCode
from pygmt.alias import Alias, AliasSystem
from pygmt.clib import Session
from pygmt.clib import Session, __gmt_version__
from pygmt.exceptions import GMTParameterError
from pygmt.helpers import build_arg_list, fmt_docstring
from pygmt.params import Box, Position
Expand Down Expand Up @@ -49,8 +50,7 @@ def magnetic_rose( # noqa: PLR0913
- A :doc:`2-character justification code </techref/justification_codes>` for a
position inside the plot, e.g., ``"TL"`` for Top Left corner inside the plot.

If not specified, defaults to the Bottom Left corner of the plot (position
``(0, 0)`` with anchor ``"BL"``).
If not specified, defaults to the Top Right corner of the plot.
width
Width of the rose in plot coordinates, or append unit ``%`` for a size in
percentage of plot width [Default is 15%].
Expand Down Expand Up @@ -109,7 +109,15 @@ def magnetic_rose( # noqa: PLR0913
"""
self._activate_figure()

position = _parse_position(position, default=Position("BL", cstype="inside"))
# The default position is set to "TR" since GMT 6.7.0, which has no default value
# in GMT 6.6.0 and earlier versions.
# TODO(GMT>6.6.0): Set 'default=None' after GMT 6.7.0.
position = _parse_position(
position,
default=None
if Version(__gmt_version__) > Version("6.6.0")
else Position("TR", cstype="inside"),
)

if declination_label is not None:
if declination is None:
Expand Down
4 changes: 2 additions & 2 deletions pygmt/tests/baseline/test_directional_rose.png.dvc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outs:
- md5: c1c167a826132bcdabc3b032438db01e
size: 8319
- md5: 10663a14391589a1854a0ea0285d1ac3
size: 8372
hash: md5
path: test_directional_rose.png
4 changes: 2 additions & 2 deletions pygmt/tests/baseline/test_directional_rose_fancy.png.dvc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outs:
- md5: 7498ed12efd8b956a0fe13d18e0e3ea9
size: 8648
- md5: 1846c3d58d0d10361040c5c846852036
size: 8593
hash: md5
path: test_directional_rose_fancy.png
4 changes: 2 additions & 2 deletions pygmt/tests/baseline/test_magnetic_rose.png.dvc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outs:
- md5: 5af8ffee19917b1fbc3371cd3aed53cd
size: 27013
- md5: 2438ead5b21314a50e5485b0aa715d88
size: 27016
hash: md5
path: test_magnetic_rose.png
Loading