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

y-axis values are displayed in ascending order in scatter plots, version 6.0.1 #5099

Open
sstripps1 opened this issue Mar 18, 2025 · 4 comments
Labels
bug something broken cs customer success P1 needed for current cycle

Comments

@sstripps1
Copy link

I am creating a scatter plot in plotly==6.0.1 using the following code and underlying data:

# Code for "Daily Views" trace
fig = go.Figure()
# Create a Plotly figure
fig.add_scatter(
    x=daily_views["viewed_date"],
    y=daily_views["view_count"],
    mode="lines+markers",
    name="Daily Views",
)
   viewed_date  view_count  cumulative_views
0   2025-02-20           2                 2
1   2025-02-21          14                16
2   2025-02-24           2                18
3   2025-02-25           2                20
4   2025-02-26           3                23
5   2025-02-27           6                29
6   2025-02-28           2                31
7   2025-03-04           1                32
8   2025-03-05           5                37
9   2025-03-06           7                44
10  2025-03-07           1                45
11  2025-03-10           1                46
12  2025-03-12           6                52
13  2025-03-13           2                54
14  2025-03-17           1                55

But the resulting figure displays the y-axis values in ascending order:

Image

The same result is seen on 6.0.0. Downgrading to 5.24.1 fixes the issue:

Image

@sstripps1 sstripps1 changed the title y-axis values are sorted in ascending order in scatter plots, version 6.0.1 y-axis values are displayed in ascending order in scatter plots, version 6.0.1 Mar 18, 2025
@sstripps1
Copy link
Author

Full pip freeze:

amqp==5.3.1
anyio==4.8.0
appnope==0.1.4
asttokens==3.0.0
async-property==0.2.2
async-timeout==5.0.1
backoff==2.2.1
billiard==4.2.1
blinker==1.9.0
cachelib==0.9.0
celery==5.4.0
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
click==8.1.8
click-didyoumean==0.3.1
click-plugins==1.1.1
click-repl==0.3.0
comm==0.2.2
cryptography==44.0.2
dash==2.18.0
dash-bootstrap-components==1.7.1
dash-core-components==2.0.0
dash-enterprise-auth==0.1.1
dash-html-components==2.0.0
dash-iconify==0.1.2
dash-table==5.0.0
dash_ag_grid==31.2.0
dash_design_kit==1.12.0
dash_mantine_components==0.14.4
debugpy==1.8.13
decorator==5.2.1
deprecation==2.1.0
dill==0.3.9
diskcache==5.6.3
exceptiongroup==1.2.2
executing==2.2.0
Flask==3.0.3
Flask-Caching==2.3.0
gql==3.5.0
graphql-core==3.2.6
gunicorn==22.0.0
h11==0.14.0
httpcore==1.0.7
httpx==0.28.1
idna==3.10
importlib_metadata==8.6.1
ipykernel==6.29.5
ipython==8.33.0
itsdangerous==2.2.0
jedi==0.19.2
Jinja2==3.1.6
jupyter_client==8.6.3
jupyter_core==5.7.2
jwcrypto==1.5.6
kombu==5.4.2
MarkupSafe==3.0.2
matplotlib-inline==0.1.7
multidict==6.1.0
multiprocess==0.70.17
narwhals==1.29.1
nest-asyncio==1.6.0
numpy==2.2.3
packaging==24.2
pandas==2.2.2
parso==0.8.4
pexpect==4.9.0
platformdirs==4.3.6
plotly==6.0.1
prompt_toolkit==3.0.50
propcache==0.3.0
psutil==7.0.0
ptyprocess==0.7.0
pure_eval==0.2.3
pycparser==2.22
Pygments==2.19.1
PyJWT==2.10.1
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-keycloak==4.7.3
pytz==2025.1
pyzmq==26.2.1
redis==5.2.1
requests==2.32.3
requests-toolbelt==1.0.0
retrying==1.3.4
six==1.17.0
sniffio==1.3.1
stack-data==0.6.3
tenacity==9.0.0
tornado==6.4.2
traitlets==5.14.3
typing_extensions==4.12.2
tzdata==2025.1
urllib3==2.3.0
vine==5.1.0
wcwidth==0.2.13
Werkzeug==3.0.6
yarl==1.18.3
zipp==3.21.0

@sstripps1
Copy link
Author

And python version 3.10.0

@gvwilson gvwilson added bug something broken P1 needed for current cycle cs customer success labels Mar 18, 2025
@emilykl
Copy link
Contributor

emilykl commented Mar 18, 2025

@sstripps1 I haven't been able to reproduce the issue so far with Plotly 6.0.1 and the code snippet below. I'd like to get to the bottom of this though -- can you share a self-contained code example, or code + CSV?

It looks to me like what's happening in your chart above is for some reason the index column of the dataframe is being used for the y-values instead of view_count -- I can see that the y-values in the chart are ascending numbers from 0-14.

import plotly.graph_objects as go
import pandas as pd


daily_views = pd.DataFrame({
    "viewed_date": ["2025-02-20", "2025-02-21", "2025-02-24", "2025-02-25", "2025-02-26", "2025-02-27", "2025-02-28", "2025-03-04", "2025-03-05", "2025-03-06", "2025-03-07", "2025-03-10", "2025-03-12", "2025-03-13", "2025-03-17"],
    "view_count": [2, 14, 2, 2, 3, 6, 2, 1, 5, 7, 1, 1, 6, 2, 1],
    "cumulative_views": [2, 16, 18, 20, 23, 29, 31, 32, 37, 44, 45, 46, 52, 54, 55],
})
fig = go.Figure()
fig.add_scatter(
    x=daily_views["viewed_date"],
    y=daily_views["view_count"],
    mode="lines+markers",
    name="Daily Views",
)
fig.show()

Image

@sstripps1
Copy link
Author

I was able to replicate the issue by wrapping the figure in a ddk.Graph - outside of this the issue doesn't occur.

However, upgrading to ddk==2.0.0 fixes it - so probably no change needed here :)

cc @emilykl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken cs customer success P1 needed for current cycle
Projects
None yet
Development

No branches or pull requests

3 participants