clustermap subplots

Solutions on MaxInterview for clustermap subplots by the best coders in the world

showing results for - "clustermap subplots"
Julian
14 Feb 2016
1import pandas as pd
2import seaborn as sns
3
4# initiliaze a dataframe with index and column names
5idf = pd.DataFrame.from_items([('A', [1, 2, 3]), ('B', [4, 5, 6]), ('C', [10, 20, 30]), ('D', [14, 15, 16])], orient='index', columns=['x', 'y', 'z'])
6
7# Plot the clustermap which will be a figure by itself
8cax = sns.clustermap(idf, col_cluster=False, row_cluster=True)
9
10# Get the column dendrogram axis
11cax_col_dend_ax = cax.ax_col_dendrogram.axes
12
13# Plot the boxplot on the column dendrogram axis
14# I still need to figure out how to show the axis for this boxplot
15idf.plot(kind='box', ax=cax_col_dend_ax)
16
17# Show the plot
18plt.show()