小编May*_*ant的帖子

如何使用 Python 在 Plotly Express 中制作水平直方图?

我正在尝试用我的数据制作水平直方图,但出现此错误:

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Run Code Online (Sandbox Code Playgroud)

当我使用时,我总是得到一个漂亮的直方图

px.histogram(df, x="columnName")
Run Code Online (Sandbox Code Playgroud)

但当我尝试将其更改为水平时,它不起作用。

px.histogram(df, y="columnName") or px.histogram(df, x="columnName", orientation='h') don't work. 
Run Code Online (Sandbox Code Playgroud)

我没有 NoneType 的数据,我什至尝试过,px.histogram(y=np.random.randn(500))但它仍然不起作用。

我尝试使用go.Figure(data=[go.Histogram(y=df['columnName'])])它确实给了我一个水平历史记录,但随后我无法根据不同的列更改颜色。

任何帮助将不胜感激,提前致谢:)

python matplotlib histogram pandas plotly

2
推荐指数
1
解决办法
2741
查看次数

标签 统计

histogram ×1

matplotlib ×1

pandas ×1

plotly ×1

python ×1