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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
### Enhancements

- Add python 3.13 to list of supported versions ([#158](https://github.com/mpytools/mplotutils/pull/158)).
- Increased test coverage ([#180](https://github.com/mpytools/mplotutils/pull/180)).
- Increased test coverage ([#180](https://github.com/mpytools/mplotutils/pull/180), and [#181](https://github.com/mpytools/mplotutils/pull/181)).

### Bug fixes

Expand Down
8 changes: 4 additions & 4 deletions mplotutils/_cartopy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ def yticklabels(

if not y_label_points:
msg = (
"WARN: no points found for ylabel\n"
"no points found for ylabel. "
f"y_lim is: {y_lim[0]:0.2f} to {y_lim[1]:0.2f}"
)
warnings.warn(msg)
warnings.warn(msg, stacklevel=2)

# get a transform instance that mpl understands
transform = ccrs.PlateCarree()._as_mpl_transform(ax)
Expand Down Expand Up @@ -421,10 +421,10 @@ def xticklabels(

if not x_label_points:
msg = (
"WARN: no points found for xlabel\n"
"no points found for xlabel. "
f"x_lim is: {x_lim[0]:0.2f} to {x_lim[1]:0.2f}"
)
warnings.warn(msg)
warnings.warn(msg, stacklevel=2)

# get a transform instance that mpl understands
transform = ccrs.PlateCarree()._as_mpl_transform(ax)
Expand Down
13 changes: 13 additions & 0 deletions mplotutils/tests/test_mapticklabels.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ def test_xticklabels_robinson(pass_ax):
assert ax.texts[-1].get_text() == "120°E"


def test_xyticklabels_not_on_map():

with subplots_context(subplot_kw=dict(projection=ccrs.PlateCarree())) as (f, ax):
# restrict extent
ax.set_extent([0, 180, -90, 0], ccrs.PlateCarree())

with pytest.warns(match="no points found for xlabel"):
mpu.xticklabels([180, 270, 360], ax=ax, size=8)

with pytest.warns(match="no points found for ylabel"):
mpu.yticklabels([0, 45, 90], ax=ax, size=8)


# TODO: https://github.com/mpytools/mplotutils/issues/48
# def test_xticklabels_robinson_180():

Expand Down