px.scatter_3d, use case where color param affects size output
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
I have created a scatter3d chart with plotly express. The scatter3d works fine with column "count" as size (fig 1). There are three big bubbles on the top layer and one on the bottom layer.
fig1
I next add the color parameter to be a column "type" in the frame. The resulting plot appears to have incorrectly swapped out "count" for "type" in the size parameter, so now the actual size param is ignored and it maps color to size. (fig 2).
fig2
import pandas as pd
import plotly.express as px
df = pd.DataFrame({
"campaign": ["funny", "funny", "funny", "funny", "patriotic", "patriotic", "patriotic", "patriotic"],
"product": ["classic", "classic", "diet", "diet", "classic", "classic", "diet", "diet"],
"type": ["click", "land", "click", "land", "click", "land", "click", "land"],
"count": [397, 108, 108, 411, 99, 410, 144, 323]
})
fig1 = px.scatter_3d(df, x="campaign", y="product", z="type", hover_data="count").update_traces({"marker": {"size": [j/10 for j in df["count"]]}})
fig2 = px.scatter_3d(df, x="campaign", y="product", z="type", hover_data="count", color="type").update_traces({"marker": {"size": [j/10 for j in df["count"]]}})
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied pandas and plotly.express px.scatter_3d reproducer, comparing fig1 and fig2 after update_traces. Inspect the generated marker size and color values to find why adding color changes the size output. Done means the count-derived marker sizes remain effective when color="type" is supplied.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100