StatsPlots dendrogram on the right side or rotated

I try to generate a heatmap with clustered rows and columns and want the dendrograms displayed on top and on the side. The top dendrogram is no problem, but I can’t find a way to create a dendrogram which is displayed from left to right (or in other words rotated by 90 degree).

Is this possible?

For the top dendrogram I am using Julia 1.2 with StatsPlots. Plots backend is GR.

The code to produce the example image (of course without the dendrogram on the right) is:

using Plots
using Distances
using Clustering
using StatsBase
using StatsPlots

pd=rand(Float64,16,7)

dist_col=pairwise(CorrDist(),pd,dims=2)
hc_col=hclust(dist_col, branchorder=:optimal)
dist_row=pairwise(CorrDist(),pd,dims=1)
hc_row=hclust(dist_row, branchorder=:optimal)

pdz=similar(pd)
for row in hc_row.order
	pdz[row,hc_col.order]=zscore(pd[row,hc_col.order])
end
nrows=length(hc_row.order)
rowlabels=(1:16)[hc_row.order]
ncols=length(hc_col.order)
collabels=(1:7)[hc_col.order]
l = grid(2,2,heights=[0.2,0.8,0.2,0.8],widths=[0.8,0.2,0.8,0.2])
plot(
	layout = l,
	plot(hc_col,xticks=false),
	plot(ticks=nothing,border=:none),
	plot(
		pdz[hc_row.order,hc_col.order],
		st=:heatmap,
		#yticks=(1:nrows,rowlabels),
		yticks=(1:nrows,rowlabels),
		xticks=(1:ncols,collabels),
		xrotation=90,
		colorbar=false
	),
	plot(ticks=nothing,border=:none)
)

And this is, what I like to produce (dendrogram on the right is the problem):

heatmapWithDendrogramOnTheRight

Are you looking for orientation = :horizontal?
Anyway, you could take a look at this WIP PR


Maybe bump the PR to get it finalised :slight_smile:

1 Like

I tried orientation = :h with no sucess, it is ignored, only the axes are exchanged :slight_smile:

I will have a look into the PR this afternoon, thanks for the hint.

I decided to provide an own approach which only addresses the orientation: