How can I control the label position and formatting using Dendrogram
? I am looking for a way which is also easy to use when passing a clustering tree as input (instead of unclustered data).
This example is from the documentation:
Dendrogram[{Entity["City", {"Paris", "IleDeFrance", "France"}],
Entity["City", {"Sydney", "NewSouthWales", "Australia"}],
Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
Entity["City", {"SanFrancisco", "California",
"UnitedStates"}]}, Left]
The formatting is not ideal and definitely not suitable for publication figures:
DendrogramPlot
from the HierarchicalClustering package uses left-alignment (or top-alignment) by default, which is better:
DendrogramPlot[{Entity["City", {"Paris", "IleDeFrance", "France"}],
Entity["City", {"Sydney", "NewSouthWales", "Australia"}],
Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
Entity["City", {"SanFrancisco", "California", "UnitedStates"}]},
DistanceFunction -> QuantityMagnitude@*GeoDistance,
LeafLabels -> (# &), Orientation -> Left]
It also has the LeafLabels
option, which makes it easier to control labelling independently of what data is passed into the function.
So this is easy to obtain too:
DendrogramPlot[{Entity["City", {"Paris", "IleDeFrance", "France"}],
Entity["City", {"Sydney", "NewSouthWales", "Australia"}],
Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
Entity["City", {"SanFrancisco", "California", "UnitedStates"}]},
DistanceFunction -> QuantityMagnitude@*GeoDistance,
LeafLabels -> (Rotate[#, Pi/2] &)]
What if I'm stuck with Dendrogram
and a pre-computed clustering tree?