AusClimateService / plotting_maps

Standardising hazard maps for ACS
4 stars 1 forks source link

acs_plotting_maps colorbar should differentiate extended scale values above and below #13

Closed xenct closed 2 months ago

xenct commented 2 months ago

Notice in this image the colours associated with >52 and <52 are the same colour. Similarly, 18. The desired behaviour is to differentiate the values that are greater than the maximum tick when 'extend' is not "neither" by using a different colour in this arrow.

image

xenct commented 2 months ago

I have updated normalisation in acs_plotting_maps to include the extend keyword. eg. norm = BoundaryNorm(bounds, cmap.N, extend = cbar_extend)

As a result, the cmap give the desired behaviour, see below.

import numpy as np
from matplotlib.colors import ListedColormap, BoundaryNorm, LinearSegmentedColormap
from acs_plotting_maps import plot_acs_hazard, regions_dict, cmap_dict, tick_dict
import xarray as xr

filename = "/g/data/ia39/ncra/heat/data/HWAtx/bias-corrected/ensemble/GWL-average/HWAtx_AGCD-05i_MME50_ssp370_v1-r1-ACS-QME-AGCD-1960-2022_GWL12.nc"
ds = xr.open_dataset(filename)
cmap_dict.update({'tasmax' : ListedColormap(colors=['#E3F4FB','#C8DEE8','#91C4EA','#56B6DC','#00A2AC','#30996C','#7FC69A','#B9DA88','#DCE799','#FCE850','#EACD44','#FED98E','#F89E64','#E67754','#D24241','#AD283B','#832D57','#A2667A','#AB9487'],name='tasmax'),})
var = "HWAtx"

plot_acs_hazard(data = ds[var],
                regions = regions_dict['ncra_regions'],
                title = "title",
                date_range = "GWL12",
                cmap = cmap_dict["tasmax"],
                ticks = np.arange(18,53,2),
                cbar_label = "degC",
                cbar_extend = "both",                
                dataset_name = "",
                outfile = "figures/out.png",
               watermark_color="k");

out