Skip to content

Commit 6c0fb83

Browse files
committed
Add over/under colors for colormap
1 parent a010381 commit 6c0fb83

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

polaris/viz/spherical.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import matplotlib.colors as cols
1010
import matplotlib.pyplot as plt
1111
import uxarray as ux
12+
from matplotlib import cm
1213
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
1314
from pyremap.descriptor.utility import interp_extrap_corner
1415

@@ -81,6 +82,13 @@ def plot_global_mpas_field(mesh_filename, da, out_filename, config,
8182
projection = cartopy.crs.PlateCarree(central_longitude=central_longitude)
8283

8384
colormap = config.get(colormap_section, 'colormap_name')
85+
cmap = cm.get_cmap(colormap)
86+
if config.has_option(colormap_section, 'under_color'):
87+
under_color = config.get(colormap_section, 'under_color')
88+
cmap.set_under(under_color)
89+
if config.has_option(colormap_section, 'over_color'):
90+
over_color = config.get(colormap_section, 'over_color')
91+
cmap.set_over(over_color)
8492

8593
norm_type = config.get(colormap_section, 'norm_type')
8694
if norm_type == 'linear':
@@ -94,7 +102,7 @@ def plot_global_mpas_field(mesh_filename, da, out_filename, config,
94102
dtype=float)
95103

96104
plot = gdf_data.hvplot.polygons(
97-
c=da.name, cmap=colormap, logz=logz,
105+
c=da.name, cmap=cmap, logz=logz,
98106
clim=tuple(colorbar_limits),
99107
clabel=colorbar_label,
100108
width=1600, height=800, title=title,

0 commit comments

Comments
 (0)