sns.clustermap
returns a 'clustergrid' which contains the subplots as 'axes': g.ax_col_dendrogram
, g.ax_row_dendrogram,
g.ax_heatmap,
g.ax_col_colors,
g.ax_row_colorsand
g.ax_cbar`.
You can use these axes to calculate a bounding box of the desired areas. See also the second answer of Save a subplot in matplotlib about how to combine areas to select an exact area of interest.
import seaborn as sns; sns.set_theme(color_codes=True)
iris = sns.load_dataset("iris")
species = iris.pop("species")
g = sns.clustermap(iris)
fig = g.fig
for ax, filename in zip([g.ax_col_dendrogram, g.ax_row_dendrogram, g.ax_heatmap],
['col_dendrogram', 'row_dendrogram', 'heatmap']):
extent = ax.get_tightbbox(fig.canvas.renderer).transformed(fig.dpi_scale_trans.inverted())
fig.savefig(f'{filename}.png', bbox_inches=extent)