# Contourplot on a Sphere in Makie.jl

**URL:** <https://discourse.julialang.org/t/contourplot-on-a-sphere-in-makie-jl/40801>\
**Category:** General Usage\
**Created:** [June 5, 2020, 10:37am UTC](https://discourse.julialang.org/t/contourplot-on-a-sphere-in-makie-jl/40801 "2020-06-05T10:37:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [June 5, 2020, 10:37am UTC](https://discourse.julialang.org/t/contourplot-on-a-sphere-in-makie-jl/40801/1 "2020-06-05T10:37:16Z")

</div>

I recently tried to get started with Makie, since I love the approach and it seems to be fairly huge in features. However, I sometimes struggle in details

I have some data on a sphere, let’s say I have a function `F` defined on the sphere. Is there a good way to get a contour-plot on a sphere?  
With

```julia
using Makie, Colors, LinearAlgebra
A = [8.0 1.0 6.0; 3.0 5.0 7.0; 4.0 9.0 2.0]
A = A + A'
A = A ./ opnorm(A)
F(p) = p' * A * p

lat = range(-π, π; length = 101)
lon = range(-π/2, π/2; length = 101)
spherical_to_euclidean(θ, φ) = [sin(θ) * cos(φ), sin(θ) * sin(φ), cos(θ)]
data = [F(spherical_to_euclidean(θ, φ)) for θ in lat, φ in lon]

```

Then of course a really neat function for a contour plot is

`contour3d(lat, lon, data, levels = 11, color = :black, linewidth = 1)`

but it’s open the 2D surface (and I would love to combine that with filled surface),  
but I would like to have this on a sphere, so maybe for

```julia
mesh_x = [spherical_to_euclidean(θ, φ)[1] for θ in lat, φ in lon]
mesh_y = [spherical_to_euclidean(θ, φ)[2] for θ in lat, φ in lon]
mesh_z = [spherical_to_euclidean(θ, φ)[3] for θ in lat, φ in lon]

```

a contour function that takes 4 arguments (the meshes and the data). Does something like this exist? That would really be nice. This matrix `A`should in the end resemble the contours from [https://manoptjl.org/stable/assets/logo.png](https://manoptjl.org/stable/assets/logo.png) just to give an example what I am aiming for.

_edit_: It would already be cool to get a fine sampling of the contours from `contours` I think, then I could `spherical_to_euclidean` those and use a heat map additionally.
