question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Most markers not visible unless chart is double-clicked with plotly.express `animation_frame`

See original GitHub issue

Creating an animated plotly.express chart using animation_frame works fine, but I realized that when selecting a certain value on the slider, most markers are not visible. It all works fine when I double click on the chart.

plotly==4.0.0 pandas==0.24.2

import random
import plotly.express as xp
import pandas as pd
import plotly

df = pd.DataFrame({
    'date': pd.date_range('2019-01-01', '2019-12-31'),
    'number': random.choices(range(1,200), k=365)
    
})
df['month'] = df['date'].dt.month
df.head()

	date	      number	 month
0	2019-01-01	152	1
1	2019-01-02	127	1
2	2019-01-03	39	1
3	2019-01-04	195	1
4	2019-01-05	69	1

xp.scatter(df, x='date', y='number', animation_frame='month')

Selecting month 6 gives the following empty chart:

Screen Shot 2019-07-20 at 10 55 01 PM

After double-clicking the chart it looks fine:

Screen Shot 2019-07-20 at 10 55 10 PM

Any idea what might be causing that? Thanks!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolaskruchtencommented, Nov 5, 2019

Today Plotly.js auto-ranges to the first frame, but in the near future it will actually transition ranges as well as data, and/or internally auto-range all frames. I don’t want to code this into the Python layer at this time as undoing that to defer to the JS layer would cause unnecessary churn.

Today the recommendation is to manually set the ranges on your animations to ensure things look good in all frames.

1reaction
nicolaskruchtencommented, Jul 21, 2019

The issue is that when using animation_frames, the axis range is computed using only the initial frame (at the moment) meaning that you must manually set the x and y range to include all of the data when animating, in order for data to be visible in all frames.

This is unfortunate, and we’ll try to automate it in the future 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Legends in Python - Plotly
Users may show or hide traces by clicking or double-clicking on their associated legend item. Traces that support legend items also support the...
Read more >
Plotly: Markers disappear when (n) points are plotted
When hovering over a point where there is one trace represented by a line, and one trace represented by a marker, plotly will...
Read more >
Visualization with Plotly.Express: Comprehensive guide
A detailed guide on how to create many visualizations with Plotly Express with layout styling, interactivity, animations, and many chart ...
Read more >
Interactive Visualization in Python with Plotly Express using ...
Your browser can't play this video. Learn more. Switch camera.
Read more >
plotly.express package — 5.11.0 documentation
When color is set and the values in the corresponding column are not numeric, ... markers (boolean (default False )) – If True...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found