# Better way for plotting millions of scatter points in GLMakie

**URL:** <https://discourse.julialang.org/t/better-way-for-plotting-millions-of-scatter-points-in-glmakie/98127>\
**Category:** General Usage\
**Tags:** makie, glmakie\
**Created:** [April 30, 2023, 4:20pm UTC](https://discourse.julialang.org/t/better-way-for-plotting-millions-of-scatter-points-in-glmakie/98127 "2023-04-30T16:20:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gavin\_Held](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gavin_held/32/49350_2.png) [@Gavin\_Held](https://discourse.julialang.org/u/Gavin_Held)\
**Post date:** [April 30, 2023, 4:20pm UTC](https://discourse.julialang.org/t/better-way-for-plotting-millions-of-scatter-points-in-glmakie/98127/1 "2023-04-30T16:20:05Z")

</div>

Hello,  
I’ve been using Makie/GLMakie for about 2 years now, and am by no means an expert. I am mostly employing makie for its 3D plotting capabilities.  
Currently, I am trying to make 3D plots of plasma turbulence data in magnetic confinement devices.

 ![Screenshot from 2023-04-30 10-53-17](https://global.discourse-cdn.com/julialang/original/3X/2/b/2b08d3458edc03f1060da996b15d0e7df38d78b4.png)

What I have so far is just the millions of data points from the simulation I ran, plotted using scatter(). The colors corresponding to values at the specific points in real space and the seemingly random cyan line is the line of sight of a diagnostic tool.

This has worked decently well for what my purposes are, but I wanted to make this plot much prettier. E.g. when I change angle of the plot, there is too great of density of points that it can’t be displayed properly.

Ideally I would like to know a better work around for getting these plots (for example maybe just making a surface of the outside most points) and also a way for plotting the cyan line, where it is a 3D cylinder, rather than a 2D line which it is now.

If anyone has suggestions it would be greatly appreciated! Thanks!

---

<div class="post-metadata">

**Author:** ![g2g](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@g2g](https://discourse.julialang.org/u/g2g)\
**Post date:** [May 1, 2023, 3:30pm UTC](https://discourse.julialang.org/t/better-way-for-plotting-millions-of-scatter-points-in-glmakie/98127/2 "2023-05-01T15:30:42Z")

</div>

> [@Gavin\_Held](#):
>
> for example maybe just making a surface of the outside most points

Are you able to calculate paths (e.g., sequences of Bezier curves) that best fit the data at different confidence intervals (e.g., 50%, 90%, 99%)? If you can, perhaps a fast and informative plot would be a different colored 3D wireframe for each confidence interval in addition to a plot of the outliers (e.g., 1% of data) using scatter().

As a way to generate simple 3D object files with code instead of interactions with a CAD application’s GUI, I’ve recently started rotating simple polygons that “extrude” (i.e., write to a 3D object file) mesh triangle faces while rotating. It is still early in its development but you can read about the general approach in this _3D Modeling for the Blind_ [essay](https://olarth.medium.com/3d-modeling-for-the-blind-ab487f11725b).

If you had confidence interval paths, it seems like it would be possible to extend “extruding a mesh while rotating” to “extruding a mesh while following a path”.

---

<div class="post-metadata">

**Author:** ![Gavin\_Held](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gavin_held/32/49350_2.png) [@Gavin\_Held](https://discourse.julialang.org/u/Gavin_Held)\
**Post date:** [May 1, 2023, 11:20pm UTC](https://discourse.julialang.org/t/better-way-for-plotting-millions-of-scatter-points-in-glmakie/98127/3 "2023-05-01T23:20:52Z")

</div>

Thank you for the very informative and quick answer.  
Calculating Bezier curves should actually be quite easy (as the many grids follow a magnetic field line). So that is definitely something I will try.

As for the 3D plotting of the off axis cylinder, that is a cool essay. Creating a cylinder object using the basis of the code written in the essay will be simple enough, but I guess my bigger question was moving and rotating a cylinder object so it is off-axis.  
If you have an easy answer to that, that would be appreciated! Otherwise, I can just do some research into it when I’ve got the time (currently in finals week so this project won’t be my top priority).

Thanks for the tips.

---

<div class="post-metadata">

**Author:** ![g2g](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@g2g](https://discourse.julialang.org/u/g2g)\
**Post date:** [May 2, 2023, 12:05am UTC](https://discourse.julialang.org/t/better-way-for-plotting-millions-of-scatter-points-in-glmakie/98127/4 "2023-05-02T00:05:41Z")

</div>

I haven’t yet done it but, in that essay, I plan to expand the function comment headers to include some examples showing that the first two points in the matrix of coordinates passed to obj\_xrotate() define the orientation and location of the cylinder.

That essay generates the cylinder using geometric algebra, which you might already be familiar given that toroids are a common geometry for magnetic confinement. In geometric algebra a 3D toroid is literally a circle times a circle. And a 4D toroid is a circle times a circle times a circle. :\*)
