您可以使用参数:
seaborn.barplot。
color: matplotlib color, optional
Color for all of the elements, or seed for a gradient palette.
用于可视化示例的例子:水平条形图
这是一个没有颜色的例子,因此结果是“彩虹”:
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="whitegrid")
f, ax = plt.subplots(figsize=(6, 15))
crashes = sns.load_dataset("car_crashes").sort_values("total", ascending=False)
sns.set_color_codes("muted")
sns.barplot(x="alcohol", y="abbrev",
data=crashes,
label="Alcohol-involved",
orient = "h")
![所有颜色的样例输出](https://istack.dev59.com/KxSPs.webp)
现在我们指定 color='b' #蓝色:
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="whitegrid")
f, ax = plt.subplots(figsize=(6, 15))
crashes = sns.load_dataset("car_crashes").sort_values("total", ascending=False)
sns.set_color_codes("muted")
sns.barplot(x="alcohol", y="abbrev",
data=crashes,
label="Alcohol-involved",
orient = "h",
color='b')
![with bars colored **blue**](https://istack.dev59.com/GjSBz.webp)