# Makie - transformation of coordinates when using PolarAxis vs Axis

**URL:** <https://discourse.julialang.org/t/makie-transformation-of-coordinates-when-using-polaraxis-vs-axis/112989>\
**Category:** Visualization\
**Tags:** question, plotting, makie\
**Created:** [April 16, 2024, 3:51am UTC](https://discourse.julialang.org/t/makie-transformation-of-coordinates-when-using-polaraxis-vs-axis/112989 "2024-04-16T03:51:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenjaminDoran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benjamindoran/32/34587_2.png) [@BenjaminDoran](https://discourse.julialang.org/u/BenjaminDoran)\
**Post date:** [April 16, 2024, 3:51am UTC](https://discourse.julialang.org/t/makie-transformation-of-coordinates-when-using-polaraxis-vs-axis/112989/1 "2024-04-16T03:51:34Z")

</div>

Is there a way to check in a makie plotting recipe what type of axis is being plotted on?

I am trying to work on a plotting recipe for AbstractTrees with both ‘dendrogram’ layouts

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/d/edf34aa5ea0658b385d7a3e56dd278c9498bd447.png)

and circular layouts

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/5/655889617425cc6d0ff5479c11f3df6f1522def1.png)

Ideally, any user has access to a `treeplot(tree, layout=:dendrogram)` or `treeplot(tree, layout=:circular)`  
with the coordinate transformations happening under the hood. But I am not sure how to setup the recipe to check which type of axis it is using, or perhaps dispatch differently based on different types of Axis.

for the dendrogram layout, I can plot

```julia
import CairoMakie as CM
using AbstractTrees

tree = ((:a, ((:b, :c), :d)), (:e, ((:f, :g), :h)), :i)
# dictionary of nodes with (x, y) coords as values
nodedict = nodepositions(tree)

# make Vector{Vector{Point2f}} 
# segments for each line going from parent node to child node
segs = makesegments(nodedict, tree)

fig = CM.Figure(size=(500,500))
ax = CM.Axis(fig[1,1])
CM.series!(ax, segs, solid_color=:black)
fig

```

Then I need to manually convert the xy coordinates to (angle,radius) coords with

```julia
nleaves = leafcount(t)
toangle(y) = 2pi * (y / (nleaves))
psegs = map(segs) do seg
    [(toangle(y), x) for (x, y) in seg]
end

```

and can plot in a PolarAxis with

```julia
fig = CM.Figure(size=(500,500))
pax = CM.PolarAxis(fig[1,1])
CM.series!(pax, psegs, solid_color=:black)
fig

```

but I am not sure where to put this behavior in a recipe

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [April 16, 2024, 12:20pm UTC](https://discourse.julialang.org/t/makie-transformation-of-coordinates-when-using-polaraxis-vs-axis/112989/2 "2024-04-16T12:20:46Z")

</div>

You could check `plot.transformation.transform_func` which will tell you which nonlinear transformation is applied to the axis!

---

<div class="post-metadata">

**Author:** ![BenjaminDoran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benjamindoran/32/34587_2.png) [@BenjaminDoran](https://discourse.julialang.org/u/BenjaminDoran)\
**Post date:** [April 17, 2024, 4:20am UTC](https://discourse.julialang.org/t/makie-transformation-of-coordinates-when-using-polaraxis-vs-axis/112989/3 "2024-04-17T04:20:40Z")

</div>

I had to do a bit of a hack with

```julia
occursin("Polar", string(plot.transformation.transform_func[]))

```

because `Makie.Polar` is not defined in MakieCore, but this does work for checking if the plotting axis is polar or not.

Thanks!
