Colours of Figanos#
On this page, we present Figanos colours and colormaps, following the IPCC visual style guide.
[1]:
%load_ext autoreload
%autoreload 2
import figanos.matplotlib as fg
fg.utils.set_mpl_style('ouranos')
import matplotlib as mpl
import glob
import os
import numpy as np
import json
from matplotlib.patches import Rectangle
from pathlib import Path
from matplotlib import pyplot as plt
ERROR 1: PROJ: proj_create_from_database: Open of /home/docs/checkouts/readthedocs.org/user_builds/figanos/conda/latest/share/proj failed
Colormaps#
Figanos tries to guess the colormap based on keywords in the attributes of the data and the divergent
argument. Users can also pass the name of a colormap (see options below) directly to the cmap
argument. If you want to suggest a new keyword, create an issue on the github repositery.
[2]:
with open(str(Path(os.getcwd()).parents[1])+ "/figanos/data/ipcc_colors/variable_groups.json") as f:
var_dict = json.load(f)
for f in np.sort(glob.glob(str(Path(os.getcwd()).parents[1])+ "/figanos/data/ipcc_colors/continuous_colormaps_rgb_0-255/*")):
name=Path(f).name.replace('.txt','')
cmap = fg.utils.create_cmap(filename=name)
fig = plt.figure()
ax = fig.add_axes([0.05, 0.80, 0.9, 0.1])
cb = mpl.colorbar.ColorbarBase(ax, orientation='horizontal',
cmap=cmap)
cb.outline.set_visible(False)
cb.ax.set_xticklabels([]);
split=name.split("_")
var = split[0]+(split[2] if len(split)==3 else '')
kw= [k for k,v in var_dict.items() if v ==var]
#plt.title(f"name: {name} \n keywords: {kw}", wrap=True)
plt.figtext(.5,.95 + (0.04 *int(len(kw)/10)),f"name: {name}", fontsize=15, ha='center')
plt.figtext(.5,.91,f"keywords: {kw}",fontsize=10,ha='center', wrap=True)
Colours#
[3]:
color_dict = fg.utils.categorical_colors()
keys = np.array(list(color_dict.keys()))
keys = np.array_split(keys, 3)
fig, ax = plt.subplots(figsize=(8,10))
ax.set_ylim(-25,3)
ax.set_xlim(0,12)
ax.set_axis_off()
for colorlist, x in zip(keys, [1, 5.5, 10]):
for y in np.arange(len(colorlist)):
ax.text(x, -y, colorlist[y],
va='bottom', ha='left',
backgroundcolor='white',
weight='normal', color='k'
)
ax.add_patch(
Rectangle(xy=(x-1, -y),width=0.5,height=0.5,
facecolor=color_dict[colorlist[y]],
edgecolor='0.8')
)