Plotly散点图仅显示每月的第一个数值,其他数值只显示悬停。

huangapple go评论66阅读模式
英文:

Plotly scatter shows only shows first value in month, only hover for others

问题

I'm scatter-plotting a timeseries with hourly values per country. Additionally, I want to be able to show the development of hourly values per day throughout the years. My input data looks like this:

datetime datetime_str country value1 value2
2014-12-07T23:00:00.000+0000 2014-12-07 GB 1234 5678
2014-12-08T00:00:00.000+0000 2014-12-08 GB 5436 9375
...

The data is present as a pandas df. The plotting code (plotly) looks like this:

fig = px.scatter(plot_df, x="value1", y="value2", animation_frame="datetime_str", animation_group="country", color="country", hover_name="country")
fig.show()

The issue now is that the plot only shows the first value per day as an actual point inside the graph. For example, if "country" has five distinct values, for each day the plot only shows five values, while it should show 5*24 values. The other ones are present in the plot though, as hover labels get displayed if I hover over them.

How do I make plotly display the other values?

Edit:
In this image you can see an example:
Plotly散点图仅显示每月的第一个数值,其他数值只显示悬停。

英文:

I'm scatter-plotting a timeseries with hourly values per country. Additionally, I want to be able to show the development of hourly values per day throughout the years. My input data looks like this:

datetime datetime_str country value1 value2
2014-12-07T23:00:00.000+0000 2014-12-07 GB 1234 5678
2014-12-08T00:00:00.000+0000 2014-12-08 GB 5436 9375
...

The data is present as a pandas df. The plotting code (plotly) looks like this:

fig = px.scatter(plot_df, x="value1", y="value2", animation_frame="datetime_str", animation_group="country", color="country", hover_name="country")
fig.show()

The issue now is that the plot only shows the first value per day as an actual point inside the graph. For example, if "country" has five distinct values, for each day the plot only show five values, while it should show 5*24 values. The other ones are present in the plot though, as hover labels get displayed if I hover over them.

How do I make plotly display the other values?

Edit:
In this image you can see an example:
Plotly散点图仅显示每月的第一个数值,其他数值只显示悬停。

答案1

得分: 0

问题是Plotly无法呈现每天的点数(“csv”模式仅能处理约1000个独立点)。我将呈现模式更改为WebGL,这在某种程度上使其工作。1

fig = px.scatter(plot_df, x="value1", y="value2", animation_frame="datetime_str", animation_group="country", color="country", hover_name="country", render_mode="webgl")
英文:

The problem was that plotly was unable to render the amount of points per day ("csv"-mode only work to about 1000 individual points). I changed the render mode to WebGL, which kinda made it work. (1)

fig = px.scatter(plot_df, x="value1", y="value2", animation_frame="datetime_str", animation_group="country", color="country", hover_name="country", render_mode="webgl")

huangapple
  • 本文由 发表于 2023年3月9日 21:33:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/75685322.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定