Skip to content

scatter plots with datetime x-axis and more than 1000 data points do not render all points #4298

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

Closed
cprice404 opened this issue Jul 27, 2023 · 4 comments

Comments

@cprice404
Copy link

I believe this issue is similar to plotly/plotly_express#145 .

I am using plotly 5.15.0 in jupyter lab 3.6.3.

My browsers (have tried firefox and chrome) support webgl.

When I render a scatter plot where the x-axis values are datetime objects,

if the plot has 1000 points, it renders fine:

size = 1000
x = np.random.randint(1690332167190, 1690332667190, size=size)
y = np.random.randint(0, 10000, size=size)
df = pd.DataFrame()
df['x'] = pd.to_datetime(x, unit='ms')
df['y'] = y
fig = px.scatter(df, x='x', y='y')
fig

image

but if I change size to 1001, the render only shows a few clusters of values on the x-axis:

image

the hover/mouseover behavior makes it clear that there are a bunch of points that exist in the spaces between what is plotted on the graph:

image

but the individual points don't render (or are rendered with the wrong x-value, not sure which).

@cprice404
Copy link
Author

i presume this has to do with the switch from svg to webgl after 1000 data points, and if I add render_mode=svg, it works properly, but that isn't an ideal solution for graphs where we will have much more than 1000 data points.

@cprice404
Copy link
Author

it has something to do with large numeric values on the x-axis because if I normalize the timestamps against the epoch by subtracting 1690330000000 from the x-values:

# x = np.random.randint(1690332167190, 1690332667190, size=size)
x = np.random.randint(2167190, 2667190, size=size)

then it renders fine with 1001 points.

@qchenevier
Copy link

It seems to be fixed with the release of v5.19.0: https://github.com/plotly/plotly.py/releases/tag/v5.19.0

@Coding-with-Adam
Copy link
Contributor

I ran the code and it works for me as well. Closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants