
上QQ阅读APP看书,第一时间看更新
How to do it...
The following code block plots a correlation matrix with a Blues colormap:
- Read the winequality data from the Excel file:
wine_quality = pd.read_csv('winequality.csv', delimiter=';')
corr = wine_quality.corr()
- Define the figure and its size:
plt.figure(figsize=(12,8))
- Plot the correlation map, the associated x and y ticks, and the colorbar:
plt.imshow(corr, cmap='Blues')
plt.colorbar()
plt.xticks(range(len(corr)),corr.columns, rotation=45)
plt.yticks(range(len(corr)),corr.columns)
- Display the figure on the screen:
plt.show()