mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.56k stars 1.92k forks source link

Plotting boxplot and clustermap on one figure. #1759

Closed dburkhardt closed 5 years ago

dburkhardt commented 5 years ago

Hi all, thank you for maintaining this wonderful package. I'm interested in creating a single figure with both a clustermap and a boxplot like this:

image

Here, the yaxis of the heatmap subplot and yaxis of the boxplot are shared.

It seems like there's no current way to do this with seaborn because the clustergrid class creates a new figure when called. I understand that I could manually cluster the rows / columns of a dataframe and just use sns.heatmap, but it would be nice to have support for figures like this.

I found one issue on SO from a few years ago that ended in a sad resolution of plotting the boxplot within one of the dendrogram axes, but that seems like a disappointing solution. (https://stackoverflow.com/questions/39170455/seaborn-clustermap-within-subplot)

Do you all have any ideas? Is this a fools errand?

Thanks in advance for your help!

-Dan

mwaskom commented 5 years ago

You can always move axes around and add other axes after creating a figure using matplotlib commands. That would be my advice.

LysSanzMoreta commented 1 year ago

@mwaskom May you please provide a code snippet/example on how to move the axes of a seaborn clustermap? I am not able to find how to do it.

Starting with 2 clustermaps, how would you plot them side by side?

Thank you in advance!