matplotlib - 为 seaborn 计数图中的所有条形应用单一颜色
问题描述
以下代码为每个类别提供不同的颜色
import seaborn as sns
sns.set(style="darkgrid")
titanic = sns.load_dataset("titanic")
ax = sns.countplot(x="class", data=titanic)
解决方案
文档:
seaborn.countplot(x=None,y=None,hue=None,data=None,order=None,hue_order=None,orient=None,color=None,palette=None,saturation=0.75,dodge=True,ax=无,**kwargs)
函数接受颜色参数,改变它来改变颜色。
推荐阅读
- sql - 从参数值中选择 SQL 列
- r - HighCharter HCAES 方法在 R Shiny Dashboard 中不产生任何可视化
- google-cloud-firestore - 仅通过云功能在 Firestore 中读写
- java - Java:如何以更快的方式从 TB 大小的文件中计算行数
- matlab - 如何有效地做一个托普利茨矩阵matlab
- python - 从 Sklearn 管道中提取具有特征名称的特征重要性
- python - celery 任务因 dlib cnn 人脸检测而失败
- javascript - 在隐身模式下运行 Chrome 时,JavaScript 源映射是否会受到影响?
- python - Pandas read_csv 具有正确的标题,但列名是 None
- excel - 使用 vba 将我当前帐户的余额从网页复制到 Excel