admin管理员组文章数量:1392094
I am trying to plot my pandas df data onto a plotly bar chart, but for some reason, instead of putting the numerical values on the chart, its just putting the order onto it.
For example, I am trying to also follow along with the docs, but it also fails on the docs' example.
The code:
import plotly.express as px
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
fig.show()
shows a chart of this:
the bar values are the indexes of the array, rather than their actual values.
I presume it might be with an issue with my install, but I am not entirely sure. Any help would be appreciated, as I haven't been able to find other solutions elsewhere.
I am trying to plot my pandas df data onto a plotly bar chart, but for some reason, instead of putting the numerical values on the chart, its just putting the order onto it.
For example, I am trying to also follow along with the docs, but it also fails on the docs' example.
The code:
import plotly.express as px
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
fig.show()
shows a chart of this:
the bar values are the indexes of the array, rather than their actual values.
I presume it might be with an issue with my install, but I am not entirely sure. Any help would be appreciated, as I haven't been able to find other solutions elsewhere.
Share Improve this question edited Mar 11 at 19:42 Derek O 19.7k4 gold badges29 silver badges49 bronze badges asked Mar 11 at 17:12 Hugh MungusHugh Mungus 551 silver badge4 bronze badges 5 |1 Answer
Reset to default 0I tested this out, and this appears to be a bug that only appears when using plotly v6.0.0
in a jupyter notebook
. For now, the issue can be worked around by downgrading the version inside the notebook: %pip install plotly==5.23.0
You'll notice that if you try to plot fig = px.bar(x=["a", "b", "c"], y=["1", "3", "2"])
you get the same, undesired behavior so it's possible that when plotly is run from a jupyter notebook and px.bar is called using lists passed to x and y, the y values are being converted to strings under the hood.
本文标签: pythonPlotly displaying numerical values as counts instead of its actual valuesStack Overflow
版权声明:本文标题:python - Plotly displaying numerical values as counts instead of its actual values? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744780199a2624661.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
%pip show plotly
in your jupyter notebook? because I cannot reproduce the behavior you're seeing in a jupyter notebook or locally – Derek O Commented Mar 11 at 20:15