Home > Mobile >  Plotly scatter with many datapoints yield blurry svg
Plotly scatter with many datapoints yield blurry svg

Time:04-22

When I export a scatterplot with 10000 datapoints to svg with fig.write_image("filename.svg") as screenshot of sharp svg with 10000 datapoints

1500 points

screenshot of sharp svg with 1000 datapoints

1000 points

screenshot of sharp svg with 1000 datapoints

(I had to make screenshots since stackoverflow does not allow .svg images)

CodePudding user response:

It looks just fine on my desktop with 10000 points: 10000 points Is it possible that you have a graphic card issue?

CodePudding user response:

I believe the answer lies here in the plotly documentation for px.scatter...

render_mode (str) – One of 'auto', 'svg' or 'webgl', default 'auto' Controls the browser API used to draw marks. 'svg’ is appropriate for figures of less than 1000 data points, and will allow for fully-vectorized output. 'webgl' is likely necessary for acceptable performance above 1000 points but rasterizes part of the output. 'auto' uses heuristics to choose the mode.

If you add render_mode = 'svg' you should see this pixilation go away.

fig =px.scatter(df, x='X', y='Y', render_mode = 'svg')
  • Related