Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

More than 1000 points in dataframe #145

Closed
educhana opened this issue Sep 26, 2019 · 5 comments
Closed

More than 1000 points in dataframe #145

educhana opened this issue Sep 26, 2019 · 5 comments

Comments

@educhana
Copy link

Any dataset (tested with scatter, line) with more than 1000 points will not show anything.

This works:
px.scatter(data[:1000], x='x', y='y')

This does not show anything:
px.scatter(data[:1001], x='x', y='y')

Is there anyway to configure it? Or is it a bug?

@nicolaskruchten
Copy link
Contributor

This is definitely unusual and doesn't occur for me. Our documentation here https://plot.ly/python/plotly-express/ contains many PX plots with dataframes larger than 1000 points.

Can you describe your environment and/or provide a sample of your data?

@educhana
Copy link
Author

Hi,
It's JupyterLab (I can reproduce it with Jupyter notebook also)

Code to reproduce the issue:

import pandas as pd
import plotly.express as px
data = pd.DataFrame(data={'x': range(10000), 'y':range(10000)})
px.scatter(data[:1001], x='x', y='y')

px.version is '0.3.0'
jupyterlab 1.1.1
The version of the notebook server is: 6.0.0
The server is running on this version of Python:
Python 3.7.0 (default, Oct 9 2018, 10:31:47)
[GCC 7.3.0]

All in a centos 6 machine

I've seen an error in the js console:
index.js:220 TypeError: Cannot read property 'regl' of null
at new C (plotly.js:69369)
at e (plotly.js:70218)
at Object.e [as plot] (plotly.js:188096)
at h (plotly.js:126031)
at Object.r.plot (plotly.js:125954)
at r.drawData (plotly.js:118146)
at Object.l.syncOrAsync (plotly.js:107399)
at Object.T [as plot] (plotly.js:112749)
at Object.z [as newPlot] (plotly.js:113019)
at Object.we [as react] (plotly.js:115043)

Looking at the source:

  if (options && options.length) options.positions = options;
  regl = options.regl; // persistent variables

  var gl = regl._gl,
      paletteTexture,
      palette = [],
      paletteIds = {},

Seems like is referencing an OpenGL context?
Interestingly, my navigator has some trouble with opengl (is disabled) due to some weird corporate policies.
Does scatter rely on opengl? AFAIK, shouldn't

@nicolaskruchten
Copy link
Contributor

Ah well that's definitely the problem then :) Yes, px.scatter will automatically switch to GL mode for sufficiently large input. You can disable this by explicitly setting render_mode="svg"

@educhana
Copy link
Author

Thanks! This works perfectly, indeed!.

px.scatter(data[:1001], x='x', y='y', render_mode="svg")

Perhaps a warning would be desirable or detecting if gl is enabled?

@artdito
Copy link

artdito commented Mar 4, 2021

@nicolaskruchten is there any way not to use webGL in other chart types?
I only see render_mode setting for line, line_polar, scatter and scatter_polar.

Thank you!

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

No branches or pull requests

3 participants