Python 如何在seaborn中使用色调、颜色、edgecolor和facecolor

Python 如何在seaborn中使用色调、颜色、edgecolor和facecolor,python,pandas,matplotlib,plot,seaborn,Python,Pandas,Matplotlib,Plot,Seaborn,我的数据集如下所示: {'prediction': {5: 'c1', 4: 'c1', 3: 'c1', 2: 'c1', 0: 'c1', 1: 'c1', 7: 'c1', 6: 'c1'}, 'variable': {5: 'ft1', 4: 'ft2', 3: 'ft3', 2: 'ft4', 0: 'ft5', 1: 'ft6', 7: 'ft7', 6: 'ft8'}, 'value': {5: 0.02091591276

我的数据集如下所示:

{'prediction': {5: 'c1',
  4: 'c1',
  3: 'c1',
  2: 'c1',
  0: 'c1',
  1: 'c1',
  7: 'c1',
  6: 'c1'},
 'variable': {5: 'ft1',
  4: 'ft2',
  3: 'ft3',
  2: 'ft4',
  0: 'ft5',
  1: 'ft6',
  7: 'ft7',
  6: 'ft8'},
 'value': {5: 0.020915912763961077,
  4: 0.020388363414781133,
  3: 0.007204373035913109,
  2: 0.0035298765062560817,
  0: -0.002049702058734183,
  1: -0.004283512505036808,
  7: -0.01882610282871816,
  6: -0.022324439779323434}}
我正在尝试制作一个条形图,它可以工作,如下所示:

sns.barplot(data=x, x='value', y='variable', 
            hue='prediction', orient="h")
这很有效

但是,我希望这些条是红色的。下:

sns.barplot(data=x, x='value', y='variable', 
            hue='prediction', color='red', orient="h")
结果:

为什么会变成灰色?我也试过了,结果也一样。如何使用seaborn v0.11.1将条形图变成橙色?

尝试使用facecolor:

输出:

颜色用于所有元素或渐变调色板的种子,而edgecolor ec和facecolor fc指定单独的元素。 ec和fc优先于色调和颜色。 使用带有色调的颜色,根据渐变为条带上色,但是由于“预测”只有一个值,因此渐变从灰色开始。 作为pd进口熊猫 导入seaborn作为sns 新数据;注:预测有不同的值 {'prediction':{5:'c1',4:'c3',3:'c3',2:'c1',0:'c1',1:'c2',7:'c2',6:'c2'},'变量:{5:'ft1',4:'ft2',3:'ft3',2:'ft4',0:'ft5',1:'ft6:'ft6'},'值':{5: 0.020915912763961077, 4: 0.020388363414781133, 3: 0.007204373035913109, 2: 0.0035298765062560817, 0: -0.002049702058734183, 1: -0.004283512505036808, 7: -0.01882610282871816, 6: -0.022324439779323434}} df=pd.DataFramex sns.barplotdata=df,x='value',y='variable',hue='prediction',orient=h,color='red',ec='k',dodge=False 请注意,dodge=False用于防止条沿分类轴移动,这在使用色调时发生

sns.barplot(data=x, x='value', y='variable', 
            hue='prediction', orient="h", facecolor='red')