How do I plot several sns.clustermap heatmaps in a single figure?
1
0
Entering edit mode
21 months ago
roy.granit ▴ 880

Hi All,

Is there a way to plot several clustermaps in a single matplotlib figure.

Edit: I'm specifically using https://scvelo.readthedocs.io/scvelo.pl.heatmap.html to generate the heatmap. This returns an object of type seaborn.matrix.ClusterGrid

Thanks!

python seaborn • 2.5k views
ADD COMMENT
0
Entering edit mode

For now I've exported the plots to png files and loaded them into subplots:

plt.figure(figsize=(30, 15))
    plt.suptitle("title", fontsize=22)

    plt.subplot(133)
    plt.imshow(mpimg.imread('./figures/heatmap_2.png',format="png"))
    plt.title("expression")
    plt.grid(None) 
    plt.axis('off')

    plt.subplot(132)
    plt.imshow(mpimg.imread('./figures/heatmap_1.png'), format="png"))
    plt.grid(None) 
    plt.axis('off')

    plt.subplot(131)
    plt.imshow(mpimg.imread('./figures/3.png',format="png"))
    #plt.grid(None) 
    plt.grid(None) 
    plt.axis('off')

    plt.show()

Not ideal, but works..

ADD REPLY
1
Entering edit mode
20 months ago

Define an ax my_ax element before, and when calling sns.clustermap use ax=my_ax as one of the parameters

f, ax = plt.subplots(figsize=(5, 6))
sns.clustermap(x="total_bill", y="tip", data=tips, ax=ax);
ADD COMMENT
0
Entering edit mode

Thanks, I'm actually using a specific type of clustermap (https://scvelo.readthedocs.io/scvelo.pl.heatmap.html) and when I try to add 'ax' to it I get an error: TypeError: heatmap() got multiple values for keyword argument 'ax'

ADD REPLY
0
Entering edit mode

I'm also trying to do this and I get the same TypeError. Any other insights?

ADD REPLY

Login before adding your answer.

Traffic: 856 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6