A colormap maps data values to visual colors. Choose one according to whether color should communicate magnitude, direction, or category. section 6.4.2
Use the following categories to match color semantics to the analytical question:
- Sequential colormaps change lightness gradually for continuous measurements; darker tones indicate larger values. section 6.4.2
- Diverging colormaps use hue for direction and lightness for strength, such as red for negative values and blue for positive values. section 6.4.2
- Categorical colormaps assign distinct colors for visual separation; colors do not represent numerical order. section 6.4.2
Survey heatmap
A normalized survey crosstab can use the grayscale sequential colormap with vmin=0 and vmax=1. Cell annotations show proportions, while darker cells indicate more respondents. section 6.4.2
fig, axis = plt.subplots()
sns.heatmap(
data=pd.crosstab(
index=survey.loc[survey["AISelect"]
!= "No, and I don't plan to", "AISelect"],
columns=survey.loc[survey["AISelect"]
!= "No, and I don't plan to", "AISent"],
normalize="index"
),
cmap="Greys",
vmin=0,
vmax=1,
square=True,
annot=True,
ax=axis
)
fig.suptitle("How favorably do different people view AI tools?")
axis.set(
xlabel="How favorable is your stance on using AI tools?",
ylabel="Do you currently use AI tools?"
)
plt.show()
Inspect a complete seaborn heatmap that applies a sequential grayscale colormap, fixed bounds, square cells, and annotations. section 6.4.2
