plotly / plotly/plotly.py

px animations does not show correctly colors if all colors are not in the first frame

Open
#2,259 15 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

For example

import pandas as pd
import plotly.express as px
dataVals = {
    'Lat': [39.783730, 7, 39.783730, 39.783730, 20, -4.03, 39.783730, 36.82, 39.783730],
    'Lon': [-100.445882, 66, -100.445882, -100.445882, 70, 5.33, -100.445882, -1.29, -100.445882],
    'Value': [40, 12, 22, 3, 60, 23, 30, 100, 200],
    'Year': ['1985', '1990', '1990', '1990', '1990', '1990', '2000', '2000', '2000'],
    'Continent Color': ["a", "b", "a", "a", "b", "c", "b", "d", "a"]
    }
data = pd.DataFrame(dataVals)

fig = px.scatter_geo(data, lat="Lat", lon="Lon", size="Value", color="Continent Color",
                     animation_frame="Year", animation_group="Continent Color",
                     projection="natural earth", size_max=200)

fig.show()

(all points are displayed with the color of continent "a"). Reported by https://community.plot.ly/t/scatter-geo-only-shows-values-with-a-certain-color-if-i-have-multiple-years-as-the-same-year/35976. Other functions such as px.scatter have the same problem.

If all colors are used for the first frame, the problem disappears.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided pandas and Plotly Express example, then compare px.scatter_geo with px.scatter while tracing how animation frames and color values are assembled. Done means colors introduced after the first frame render with their own colors in animated charts, including the reported example.

Written by the indexing model from the issue text.

Assessment

Tech stack
plotly, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.