# StatsPlots dendrogram on the right side or rotated

**URL:** <https://discourse.julialang.org/t/statsplots-dendrogram-on-the-right-side-or-rotated/31348>\
**Category:** Visualization\
**Tags:** question, plotting\
**Created:** [November 21, 2019, 12:47pm UTC](https://discourse.julialang.org/t/statsplots-dendrogram-on-the-right-side-or-rotated/31348 "2019-11-21T12:47:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [November 21, 2019, 12:47pm UTC](https://discourse.julialang.org/t/statsplots-dendrogram-on-the-right-side-or-rotated/31348/1 "2019-11-21T12:47:16Z")

</div>

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:

```julia
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](https://global.discourse-cdn.com/julialang/original/3X/1/1/1122a63e98320c7e23d67a921bf737d88d83cff1.jpeg)

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [November 22, 2019, 9:11am UTC](https://discourse.julialang.org/t/statsplots-dendrogram-on-the-right-side-or-rotated/31348/2 "2019-11-22T09:11:52Z")

</div>

Are you looking for `orientation = :horizontal`?  
Anyway, you could take a look at this WIP PR  
[https://github.com/JuliaPlots/StatsPlots.jl/pull/214](https://github.com/JuliaPlots/StatsPlots.jl/pull/214)  
Maybe bump the PR to get it finalised 🙂

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [November 22, 2019, 9:28am UTC](https://discourse.julialang.org/t/statsplots-dendrogram-on-the-right-side-or-rotated/31348/3 "2019-11-22T09:28:48Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [November 22, 2019, 12:39pm UTC](https://discourse.julialang.org/t/statsplots-dendrogram-on-the-right-side-or-rotated/31348/4 "2019-11-22T12:39:42Z")

</div>

I decided to provide an own approach which only addresses the orientation:  
[https://github.com/JuliaPlots/StatsPlots.jl/pull/271](https://github.com/JuliaPlots/StatsPlots.jl/pull/271)
