How it works...

Here is the explanation of how it works:

  • pd.read_csv() reads the winequality data, and wine_quality.corr() computes the correlation matrix.
  • plt.imshow(corr, cmap='Blues') displays the correlation matrix as an image and applies one of the standard colormaps: Blues.
  • plt.colorbar() displays the color scale indicating which color share represents which data range.
  • plt.xticks() and plt.yticks() plot the tickers (one for each attribute in the dataset) and the corresponding ticker labels for the x and the y axis. Argument rotation=45 in plt.xticks() indicates that ticker lables should be placed at 45 degrees to the corresponding axis.

You should see the following heatmap. As expected, the data ranges from -0.6 to 1.0 (correlations can range only between -1.0 and 1.0). 1.0 is represented with a dark blue color at one end, and on the other end a white color represents -1, and dark to lighter shades in between dark blue and white colors, represent numbers between 1.0 and -1.0: