-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Description
I was looking at the code and there is arguments in the treeplot/treeplot! functions that indicate that there was an idea to add markers in the node positions, but it's not currently implemented.
This is pretty useful to map some analysis into each branch.
Validation and testing
I made a preliminar version of the recipe treescatter as follows:
Makie.@recipe(TreeScatter, tree) do scene
attr = Makie.Attributes(
alpha = @something(Makie.theme(scene, :alpha), 1.0),
showroot = false,
layoutstyle = :dendrogram,
ignorebranchlengths = false,
marker = @something(Makie.theme(scene, :marker), :circle),
markercolor = @something(Makie.theme(scene, :color), :black),
markersize = @something(Makie.theme(scene, :markersize), 5),
openangle = 0,
)
Makie.MakieCore.generic_plot_attributes!(attr)
return Makie.MakieCore.colormap_attributes!(attr, Makie.theme(scene, :colormap))
end
function Makie.plot!(plt::TreeScatter)
nleaves = BasicTreePlots.leafcount(plt.tree[])
toangle(y) = (y / (nleaves)) * (2π - (plt.openangle[] % 2pi))
## Setup tree layout
nodecoords = BasicTreePlots.nodepositions(
plt.tree[];
showroot = plt.showroot[],
layoutstyle = plt.layoutstyle[],
)
maxleafposition = argmax(x -> x[1], values(nodecoords))
## Transform coordinate if plotting in Polar Axis
if occursin("Polar", string(plt.transformation.transform_func[]))
nodecoords = Dict(node => (toangle(y), x) for (node, (x, y)) in nodecoords)
end
## Add markers in nodes
return scatter!(
plt,
collect(values(nodecoords)),
alpha = plt.alpha[],
marker = plt.marker[],
markersize = plt.markersize[],
color = plt.markercolor[],
colormap = plt.colormap[]
)
endThis produces something like this:
begin
tree = tree = ((:a, :b), (:c, (:d, :e)))
f = Figure()
ax = Axis(f[1, 1])
treeplot!(ax, tree)
treescatter!(
ax,
tree,
alpha= 0.5,
marker = :utriangle,
markersize = (rand(9) .* 10) .^ 2,
markercolor = rand(9),
colormap = [:tomato, :slategray2]
)
f
endMotivation
No response
Target audience
No response
Can you help?
I can push this feature into a pull request if it looks good to you.
Metadata
Metadata
Assignees
Labels
No labels
