【问题标题】:seaborn hue parameter not working correctlyseaborn 色调参数无法正常工作
【发布时间】:2016-04-23 15:42:43
【问题描述】:

我无法让 seaborn 色调按价值着色。我的数据在 pandas df 中,我正在使用条形图。

sns.barplot(x = plot_data['gene'], y = plot_data['freq'],
            hue=plot_data["type"],palette={"type1":"red", "type2":"blue"}, ax=ax2)

我对出现在某些地方的灰色条感到困惑。我希望只有红色和蓝色条,我确信这是数据中仅有的两种类型。

【问题讨论】:

  • 请检查数据并且您没有使用嵌套数据:stanford.edu/~mwaskom/software/seaborn/generated/…
  • 我不认为我的数据是嵌套的 - 每个数据点都在一行中,“类型”列确定类别。
  • 只有三行数据你能做到这一点吗?并向我们​​展示数据?
  • 没有样本数据就无法重现。

标签: python seaborn


【解决方案1】:

我建议你按水平顺序绘制 seaborn barplot,因为垂直方向不显示正确的方式,这可能是你说seaborn barplothue 参数不起作用。

并使用

plt.figure(figsize(9,200)) # for figure size in ration 9:200

您可以根据需要进行更改。

【讨论】:

    猜你喜欢
    • 2023-03-06
    • 1970-01-01
    • 2014-02-22
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 2016-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多