2017-06-01 3 views
-2

J'utilise Spyder 3.1.2, Python 3.6.0 (Annaconda)Tous les graphiques sont écrits dans la même parcelle

Quand je lance le code - tous ces graphiques apparaissent sur la même parcelle?

données est une table de données

import seaborn as sns 

#============================================================================== 
# Co-orelation text matrix and the heatMap 
#============================================================================== 

    sns.heatmap(corrmat, vmax=1., square=True).xaxis.tick_top() 

#============================================================================== 
# Scatter plot using Principal components 
#============================================================================== 

    sns.lmplot("PC1", "PC2", bar, hue="Class", fit_reg=True) 


#============================================================================== 
# Profile plot 
#============================================================================== 

    ax = data[["V2","V3","V4","V5","V6"]].plot() 
    ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)); 

Répondre

0

Vous devez utiliser les mots-clés ax ici.

import matplotlib.pyplot as plt 
import seaborn as sns 

#if you want them stacked vertically 
f, (ax1, ax2, ax3) = plt.subplots(1, 3) 

sns.heatmap(corrmat, vmax=1., square=True, ax=ax1) 
ax1.xaxis.tick_top() 

sns.lmplot("PC1", "PC2", bar, hue="Class", fit_reg=True, ax=ax2) 

data[["V2","V3","V4","V5","V6"]].plot(ax=ax3) 
ax3.legend(loc='center left', bbox_to_anchor=(1, 0.5)) 

Vous pouvez aussi simplement appeler plt.figure() avant chaque appel de traçage, qui vous donnera 3 parcelles distinctes.