更改df.reset_index()。plot条形图中的颜色

问题描述 投票:0回答:1

我有下面的代码生成显示的图形。如何将橙色更改为红色?我曾尝试说c =“ red”,但这会使橙色和蓝色条变成红色

df.reset_index().plot(x="index", y=["Ic_tape_inner", "Ic_tape_outer"], kind="bar", figsize=(10,6))enter image description here

dataframe matplotlib colors bar-chart
1个回答
0
投票

[将颜色添加为列表,例如color=["blue","red"]

 (pd.DataFrame({"Ic_tape_inner":[10,12,13],"Ic_tape_outer":[1,2,3]})
  .reset_index().plot(x="index", y=["Ic_tape_inner", "Ic_tape_outer"],
   kind="bar", figsize=(10,6),color=["blue","red"])
 )

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.