Getting an empty scatterplot, but with hover info and legend

I am trying to create a very simple scatter plot in a jupyter notebook (plotly version 4.9.0).

fig = px.scatter(df, x=“pca1”, y=“pca2”, colour=“label”)
fig.show()

This shows an empty plot: the range for the x and y axis corresponds roughly to the min and max of the pca1 and pca2 columns, if I move the mouse over the plotting area, the hover information for the data points is shown, but there are no data points?
This is extremely frustrating, I have no idea what could possibly go wrong here, especially as I tried the iris dataset example in the next cell and it works just fine.

OK, I found the problem and it is a bit weird:

  • plotly automatically changes the method used for rendering interactive plots to using webgl if there are more than 1000 data points
  • I was running my notebook on a screen which did not support webgl
  • when this fails, no warning or other feedback is given and one ends up with the mysterious empty plot
  • the default behaviour of “auto” can be modified with the “render_mode” parameter of “scatter”, when setting to “svg” the datapoints will be shown
  • it may also work to use a different renderer, not totally sure how render_mode and renderers interact
2 Likes

Thanks for providing the solution, you saved me a lot of investigation time !

Odd behavior indeed.