# PGFPlots Healpix / Mollweide / Aitoff projections?

**URL:** <https://discourse.julialang.org/t/pgfplots-healpix-mollweide-aitoff-projections/106832>\
**Category:** Visualization\
**Tags:** plotting, pgfplotsx\
**Created:** [November 28, 2023, 9:30am UTC](https://discourse.julialang.org/t/pgfplots-healpix-mollweide-aitoff-projections/106832 "2023-11-28T09:30:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tamasgal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamasgal/32/27946_2.png) [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Post date:** [November 28, 2023, 9:30am UTC](https://discourse.julialang.org/t/pgfplots-healpix-mollweide-aitoff-projections/106832/1 "2023-11-28T09:30:40Z")

</div>

I really like `PGFPlotsX.jl` to create plots which seamlessly integrate into papers but I now I need to make a bunch of Healpix Mollweide projections to visualise data spread on the surface on a sphere (essentially skymaps) and I have not really figured out how. I searched the web but it seems that either nobody is talking about, or nobody is using PGFPlots to do this 😉

The package `Healpix.jl` already provides a recipe for `Plots.jl` which works:

```julia
julia> using Healpix

julia> using Plots

julia> m = HealpixMap{Float64, RingOrder}(32);

julia> m[ang2pixRing(m.resolution, π/4, 0.0)] = 250
250

julia> m[ang2pixRing(m.resolution, 0.0, 0.0)] = 200
200

julia> m[ang2pixRing(m.resolution, 0.42, 0.23)] = 300
300

julia> plot(m)

```

and produces this beauty:

 ![Screenshot 2023-11-28 at 10.26.06](https://global.discourse-cdn.com/julialang/original/3X/2/0/20b1c6b3bb92829fa1ab101d5f55630aba28e0a9.png)

But I need to adjust a lot of things and annotate stuff etc. which I find much more easier (and possible) in `PGFPlots` via `PGFPlotsX.jl`. I played around with `Plots.jl` but I find myself struggling really with finding the right point to override defaults and modify specific aspects of the image.

So my question: does anybody here by chance has some experience in creating healpix/mollweide/aitoff projections with PGFPlots?

I fear the answer is “no, take what’s there (`Plots.jl`) and try to improve”, but I’d give up so much freedom (and free time 😆 ) by not using PGF.

Edit: let me add a nicer example output. The real fun begins with drawing lines, circles etc., modifying the colorbar and so on. Maybe it’s perfectly doable in `Plots.jl`, but I am a bit lost:

 ![Screenshot 2023-11-28 at 10.34.50](https://global.discourse-cdn.com/julialang/original/3X/5/2/52d530956bbf65a94b9b43953317fb71939ac6cb.png)

---

<div class="post-metadata">

**Author:** ![tamasgal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamasgal/32/27946_2.png) [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Post date:** [March 12, 2024, 6:24pm UTC](https://discourse.julialang.org/t/pgfplots-healpix-mollweide-aitoff-projections/106832/2 "2024-03-12T18:24:41Z")

</div>

OK, for the sake of completeness, I manage to get something but I’ll stop working on it since I think that the output format will not be suitable for a nice user experience 😉 I thought that some renderers would somehow manage to simplify and pixelise the output but apparently everything is vectorised, which means that the output file is huge (in my case 10MB) and on slow system the scrolling is causing a lot of stress on the hardware.

Anyways, here is the rough idea:

```julia
using PGFPlotsX

out = rand(100, 100) # this is basically a heatmap-like structure

fig = @pgf Axis(
    {
        view = (0, 90),
        colorbar,
        "colormap/viridis"
    },
    Plot3(
        {
            surf,
            shader = "flat",
        },
        Table(TableData(1:size(out)[1], 1:size(out)[2], out)))
)

```

![Screenshot 2024-03-12 at 19.25.36](https://global.discourse-cdn.com/julialang/original/3X/f/a/fa54abc9b46b24c72bea35d2456f2f1861e13bc3.png)

To display a `HealpixMap` from `Healpix.jl`, we need to do:

```julia
m = HealpixMap{Float64, RingOrder}(32);

# fill the map
# ...

img, mask, anymasked = mollweide(m, Dict())

```

and `img` is our `out` above.

And voila, the skymap from above:

 ![Screenshot 2024-03-12 at 19.24.14](https://global.discourse-cdn.com/julialang/original/3X/1/0/10e3569666755ba67baa62c14be3110ac8379b3b.png)
