Search code examples
pythonmatplotlibtime-seriesplotlyscatter-plot

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 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: Image showing an "invisible" point.


Solution

  • 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")