Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hadrienj/842f20e1cff6f486a62d53cb402dadfd to your computer and use it in GitHub Desktop.
Save hadrienj/842f20e1cff6f486a62d53cb402dadfd to your computer and use it in GitHub Desktop.
def plotDataAndCov(data):
ACov = np.cov(data, rowvar=False, bias=True)
print 'Covariance matrix:\n', ACov
fig, ax = plt.subplots(nrows=1, ncols=2)
fig.set_size_inches(10, 10)
ax0 = plt.subplot(2, 2, 1)
# Choosing the colors
cmap = sns.color_palette("GnBu", 10)
sns.heatmap(ACov, cmap=cmap, vmin=0)
ax1 = plt.subplot(2, 2, 2)
# data can include the colors
if data.shape[1]==3:
c=data[:,2]
else:
c="#0A98BE"
ax1.scatter(data[:,0], data[:,1], c=c, s=40)
# Remove the top and right axes from the data plot
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment