aaanalysis.plot_get_cmap
- aaanalysis.plot_get_cmap(name='CPP', n_colors=101, facecolor_dark=False)[source]
Get colormaps specified for AAanalysis.
Added in version 0.1.2.
- Parameters:
name ({'CPP', 'SHAP'}, default='CPP') –
The name of the AAanalysis color palettes.
CPP: Continuous colormap for CPP plots.SHAP: Continuous colormap for CPP-SHP plots.
n_colors (int, default=101) – Number of colors. Must be at least 3.
facecolor_dark (bool, optional) – Whether central color in is black (if
True) or white (ifFalse).
- Returns:
List with colors given as RGB tuples.
- Return type:
cmap
See also
seaborn.color_palette()function to generate a color palette in seaborn.seaborn.light_palette function()to generate a lighter color palettes.The SHAP package.
Examples
Continuous color maps (cmap) for ‘CPP plots’ and ‘CPP-SHAP plots’ can be retrieved using
aa.plot_get_cmap(), where the number of colors is set usingn_colors:import matplotlib.pyplot as plt import seaborn as sns import aaanalysis as aa data = {'Classes': ['Negative values', 'Middle value (0)', 'Positive values',], 'Values': [13, 23, 33]} aa.plot_settings(font_scale=0.9) colors = aa.plot_get_cmap(n_colors=3) sns.barplot(data=data, x='Classes', y='Values', palette=colors, hue="Classes") plt.show()
For ‘CPP plots’, we recommend using a white facecolor using
facecolor_dark=False:colors = aa.plot_get_cmap(name="CPP", n_colors=3, facecolor_dark=False) sns.barplot(data=data, x='Classes', y='Values', palette=colors, hue="Classes", edgecolor="black") plt.show()
For ‘CPP-SHAP plots’, we recommend using a dark facecolor:
colors = aa.plot_get_cmap(name="SHAP", n_colors=3, facecolor_dark=True) sns.barplot(data=data, x='Classes', y='Values', palette=colors, hue="Classes") plt.show()
The number of colors steps can be adjusted to any number integer number:
n = 11 colors = aa.plot_get_cmap(n_colors=n) sns.palplot(colors) plt.show() colors = aa.plot_get_cmap(n_colors=n, facecolor_dark=False) sns.palplot(colors) plt.show() colors = aa.plot_get_cmap(n_colors=n, facecolor_dark=True) sns.palplot(colors) plt.show()