【问题标题】:Make seaborn factorplot black and white将seaborn factorplot设为黑白
【发布时间】:2019-07-29 14:21:42
【问题描述】:

给定一个像这里这样的海洋因子图:

df = pd.DataFrame({'X_Axis':[1,3,5,7,10,20],
                   'col_2':[.4,.5,.4,.5,.5,.4],
                   'col_3':[.7,.8,.9,.4,.2,.3],
                   'col_4':[.1,.3,.5,.7,.1,.0],
                   'col_5':[.5,.3,.6,.9,.2,.4]})

df = df.melt('X_Axis', var_name='cols',  value_name='vals')
g = sns.factorplot(x="X_Axis", y="vals", hue='cols', data=df)

我正在尝试使情节黑白分明。某个图应该是黑色的(比如 col2),而其余的应该是灰色的。

提前感谢您的帮助!

【问题讨论】:

    标签: python seaborn


    【解决方案1】:

    你可以使用调色板属性:

    g = sns.factorplot(x="X_Axis", y="vals", hue='cols', data=df,  palette=['black', 'grey', 'grey', 'grey'])
    

    【讨论】:

      猜你喜欢
      • 2017-01-02
      • 2014-10-05
      • 2014-11-13
      • 1970-01-01
      • 2018-07-09
      • 2018-08-05
      • 2015-09-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多