Skip to content

Commit 4985c2e

Browse files
cvanelterenbeckermrpre-commit-ci[bot]
authored
Allow rasterization on GeoFeatures. (#220)
* Don't apply sharing on axes that are not Geo * add unittest with image comp * update comment * fix unittest * confirm fix and is caused by colorbar * update comment * add keywords * black formatting * add more GeoFeatures * typo * fix typos and add unittest * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Matthew R. Becker <beckermr@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 09853eb commit 4985c2e

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

ultraplot/internals/rcsetup.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,11 @@ def copy(self):
960960
"Line width for country border lines.",
961961
),
962962
"borders.zorder": (ZLINES, _validate_float, "Z-order for country border lines."),
963+
"borders.rasterized": (
964+
False,
965+
_validate_bool,
966+
"Toggles rasterization on or off for border feature in GeoAxes.",
967+
),
963968
# Bottom subplot labels
964969
"bottomlabel.color": (
965970
BLACK,
@@ -997,6 +1002,11 @@ def copy(self):
9971002
"coast.color": (BLACK, _validate_color, "Line color for coast lines."),
9981003
"coast.linewidth": (LINEWIDTH, _validate_pt, "Line width for coast lines."),
9991004
"coast.zorder": (ZLINES, _validate_float, "Z-order for coast lines."),
1005+
"coast.rasterized": (
1006+
False,
1007+
_validate_bool,
1008+
"Toggles the rasterization of the coastlines feature for GeoAxes.",
1009+
),
10001010
# Colorbars
10011011
"colorbar.edgecolor": (
10021012
BLACK,
@@ -1457,6 +1467,11 @@ def copy(self):
14571467
),
14581468
"lakes.color": (WHITE, _validate_color, "Face color for lake patches."),
14591469
"lakes.zorder": (ZPATCHES, _validate_float, "Z-order for lake patches."),
1470+
"lakes.rasterized": (
1471+
False,
1472+
_validate_bool,
1473+
"Toggles rasterization on or off for lake feature",
1474+
),
14601475
# Land patches
14611476
"land": (False, _validate_bool, "Toggles land patches on and off."),
14621477
"land.alpha": (
@@ -1466,6 +1481,11 @@ def copy(self):
14661481
),
14671482
"land.color": (BLACK, _validate_color, "Face color for land patches."),
14681483
"land.zorder": (ZPATCHES, _validate_float, "Z-order for land patches."),
1484+
"land.rasterized": (
1485+
False,
1486+
_validate_bool,
1487+
"Toggles the rasterization of the land feature.",
1488+
),
14691489
# Left subplot labels
14701490
"leftlabel.color": (
14711491
BLACK,
@@ -1564,6 +1584,11 @@ def copy(self):
15641584
),
15651585
"ocean.color": (WHITE, _validate_color, "Face color for ocean patches."),
15661586
"ocean.zorder": (ZPATCHES, _validate_float, "Z-order for ocean patches."),
1587+
"ocean.rasterized": (
1588+
False,
1589+
_validate_bool,
1590+
"Turns rasterization on or off for the oceans feature for GeoAxes.",
1591+
),
15671592
# Geographic resolution
15681593
"reso": (
15691594
"lo",
@@ -1608,6 +1633,11 @@ def copy(self):
16081633
"rivers.color": (BLACK, _validate_color, "Line color for river lines."),
16091634
"rivers.linewidth": (LINEWIDTH, _validate_pt, "Line width for river lines."),
16101635
"rivers.zorder": (ZLINES, _validate_float, "Z-order for river lines."),
1636+
"rivers.rasterized": (
1637+
False,
1638+
_validate_bool,
1639+
"Toggles rasterization on or off for rivers feature for GeoAxes.",
1640+
),
16111641
# Subplots settings
16121642
"subplots.align": (
16131643
False,

ultraplot/tests/test_geographic.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,24 @@ def test_cartesian_and_geo():
609609
return fig
610610

611611

612+
def test_rasterize_feature():
613+
fig, ax = uplt.subplots(proj="cyl")
614+
ax.format(
615+
land=True,
616+
landrasterized=True,
617+
ocean=True,
618+
oceanrasterized=True,
619+
rivers=True,
620+
riversrasterized=True,
621+
borders=True,
622+
bordersrasterized=True,
623+
)
624+
for feature in "land ocean rivers borders".split():
625+
feat = getattr(ax[0], f"_{feature}_feature")
626+
assert feat._kwargs["rasterized"]
627+
uplt.close(fig)
628+
629+
612630
def test_check_tricontourf():
613631
"""
614632
Ensure that tricontour functions are getting

0 commit comments

Comments
 (0)