所有图形都写入同一个图

All graphs are written to the same plot

我正在使用Spyder 3.1.2, Python 3.6.0 (Annaconda)

当我 运行 代码时 - 所有这些图表都显示在同一个图上?

数据是一个数据table

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));

您应该在此处使用 ax 关键字。

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))

您也可以在每次绘图调用之前调用 plt.figure(),这将为您提供 3 个单独的绘图。