Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

px.scatter_3d, use case where color param affects size output #5047

Open
ua-chjb opened this issue Feb 20, 2025 · 2 comments
Open

px.scatter_3d, use case where color param affects size output #5047

ua-chjb opened this issue Feb 20, 2025 · 2 comments
Labels
bug something broken P2 considered for next cycle

Comments

@ua-chjb
Copy link

ua-chjb commented Feb 20, 2025

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.

Image
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).

Image
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"]]}})
@gvwilson
Copy link
Contributor

Thanks for the report @ua-chjb - can you please let us know which versions of Python and Plotly you are using, on which OS and with which browser? Thanks - @gvwilson

@gvwilson gvwilson added bug something broken P2 considered for next cycle labels Feb 20, 2025
@ua-chjb
Copy link
Author

ua-chjb commented Feb 21, 2025

Python 3.9.12, running on Windows 10 in Jupyter Lab on Chrome

Name: plotly
Version: 5.24.1
Summary: An open-source, interactive data visualization library for Python
Home-page: https://plotly.com/python/
Author: Chris P
Author-email: [email protected]
License: MIT
Location: c:\users\benno\appdata\local\programs\python\python39\lib\site-package
s
Requires: packaging, tenacity
Required-by: dash


Name: jupyter
Version: 1.1.1
Summary: Jupyter metapackage. Install all the Jupyter components in one go.
Home-page: https://jupyter.org
Author: Jupyter Development Team
Author-email: [email protected]
License: BSD
Location: c:\users\benno\appdata\local\programs\python\python39\lib\site-package
s
Requires: ipykernel, ipywidgets, jupyter-console, jupyterlab, nbconvert, noteboo
k
Required-by:

Name: jupyterlab
Version: 4.3.2
Summary: JupyterLab computational environment
Home-page:
Author:
Author-email: Jupyter Development Team <[email protected]>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P2 considered for next cycle
Projects
None yet
Development

No branches or pull requests

2 participants