Complete the code to import the matplotlib library with the common alias.
import [1] as plt
We import matplotlib.pyplot as plt to access plotting functions.
Complete the code to create a colorblind-friendly palette using seaborn.
palette = sns.color_palette("[1]")
The 'colorblind' palette in seaborn is designed to be friendly for colorblind viewers.
Fix the error in the code to apply a colorblind-friendly palette to a bar plot.
sns.barplot(x='category', y='value', data=df, palette=[1])
The palette argument accepts a list of colors, which sns.color_palette("colorblind") returns. (Note: "colorblind" string also works.)
Fill both blanks to create a dictionary of colors from the colorblind palette for categories 'A' and 'B'.
colors = {'A': palette[[1]], 'B': palette[[2]]}The first two colors in the colorblind palette are at indexes 0 and 1.
Fill all three blanks to create a scatter plot with colorblind-friendly colors and a legend.
for cat, color in colors.items(): subset = df[df['category'] == [1]] plt.scatter(subset['x'], subset['y'], color=[2], label=[3]) plt.legend()
We filter by category 'cat', use the color variable for color, and label points by 'cat'.