【问题标题】:Is there a way of getting multiple levels of hue in Seaborn or Matplotlib?有没有办法在 Seaborn 或 Matplotlib 中获得多层次的色调?
【发布时间】:2020-04-24 12:12:10
【问题描述】:

我可以得到我需要的表格,

但我可以用 3 个维度管理的最接近的情节是:

当我试图得到这样的东西时:

group_fields = ['ABS', 'Schooling']
output_fields = ['Gain S/L per Term', 'Gain Read per term', 'Gain Write per term']

table_data = school[group_fields + output_fields]
table = table_data.groupby(group_fields).mean()
display(table)

long_school = pd.melt(school, id_vars=['ABS', 'Schooling'], var_name='Macro', 
                      value_vars=outputFields, value_name='Increase')

sns.catplot(data=long_school, kind='bar', col='Schooling', x='ABS', hue='Macro', ci=False, y='Increase')

【问题讨论】:

  • “多层次的色调”是什么意思?

标签: python pandas matplotlib jupyter seaborn


【解决方案1】:

您想为调色板定义一个颜色列表。有关 seaborn 的示例,请参阅 here

【讨论】:

    【解决方案2】:

    也许检查一下样式选项?在 Seaborn 线图中,您可以通过色调变量来着色,并通过样式变量来获得线条图案。

    【讨论】:

      猜你喜欢
      • 2015-09-23
      • 1970-01-01
      • 2022-12-10
      • 2020-10-18
      • 1970-01-01
      • 2021-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多