我正在尝试使用 plotly.express 作为箱线图绘制我存储在 Pandas DataFrame 中的数据。df 如下所示:
这是我在 plotly 中制作基本箱线图的代码:
import plotly.express as px
fig = px.box(df1, x="Condition",
y="Number of Groups")
fig.show()
Run Code Online (Sandbox Code Playgroud)
现在,我想用不同的颜色为我使用的每个条件着色:
import plotly.express as px
fig = px.box(df1, x="Condition",
y="Number of Groups",
color="Condition")
fig.show()
Run Code Online (Sandbox Code Playgroud)
这是已被固定在4.8版中的错误plotly和版本解决方法下面是添加boxmode="overlay"里面px.box()打电话时color被设置为相同的值x。我应该补充一点,这同样适用于px.violin和分别px.strip用violinmode和绘制stripmode:)