GLMakie - Polar heatmap/ millions of Polygons(?)


I am trying to plot (a lot of) data in a live “polar heatmap”. A triangular visualization like below is ok.

For now I have used polygons by modifying this example:

However my current solution is way to slow when I add millions of point.
I am not sure polygons like below code are the way to go, maybe someone have a tip on a more efficient way to draw something like this in GLMakie?
(overlapping triangles? something completly different?)

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


using GLMakie, GeometryBasics, BenchmarkTools, StaticArrays

function calc_polygons(start_θ_deg::Float64, end_θ_deg::Float64, amplitude::Vector{Float64})
    # number of cells
    n = length(amplitude)

    # start point
    p₀_start_az = Point2f(0, 0)
    p₀_end_az = Point2f(0, 0)

    # Pre-calculate sin and cos outside the loop to avoid redundant calculations.
    start_θ_rad = deg2rad(start_θ_deg)
    end_θ_rad = deg2rad(end_θ_deg)
    (start_θ_sin, start_θ_cos) = sincos(start_θ_rad)
    (end_θ_sin, end_θ_cos) = sincos(end_θ_rad)

    # Pre-calculate start_θ_offset and end_θ_offset outside the loop to avoid redundant calculations.
    start_θ_offset = Point2f(start_θ_cos, start_θ_sin)
    end_θ_offset = Point2f(end_θ_cos, end_θ_sin)

    polygons = [Polygon([
        p₀_end_az   + (i-1) * end_θ_offset, 
        p₀_start_az + (i-1) * start_θ_offset, 
        p₀_start_az +  i    * start_θ_offset, 
        p₀_end_az   +  i    * end_θ_offset
        ]) for i in 1:n]

    # convert amplitude vector to color vector
    rgb_colors = [RGBf(amp,0,0) for amp in amplitude]

    return (polygons, rgb_colors)

function main()
    polygons, rgb_colors = calc_polygons(20., 30., rand(5));
    poly(polygons, color = rgb_colors, overdraw = true)


Not an exact solution to your problem but did you try using a standard heatmap with InteractiveViz ?
You could rasterize your polygons into a big matrix and then plot it (using NaNs for the “void” pixels)
It depends on your computer of course but it can plot interactive heatmaps of several billion points