text_html_output_1.png
import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

data = pd.read_csv('../input/world-happiness/2019.csv')

correlation_matrix_data = data.corr()

# Correlation Matrix function in Matplotlib 👩‍🚒
fig, ax= plt.subplots(figsize=(6,6))
cp=ax.matshow(correlation_matrix_data)
ax.set_title('Correlation Matrix Plot')
# Annotate the values into correlation plot
for (i, j), z in np.ndenumerate(correlation_matrix_data):
    ax.text(j, i, '{:0.2f}'.format(z), ha='center', va='center')
fig.colorbar(cp, ax=ax,fraction=0.046, pad=0.04);

# fraction=0.046, pad=0.04 seem like a magical combination to keep the colorbar scaled to the plot all the time 🙄

Group = np.repeat(np.array(['Q1', 'Q2', 'Q3']), [52, 52, 52], axis=0)
Group = pd.Series(Group)
pair_plot_data = data[['Social support', 'Healthy life expectancy', 'Score', 'GDP per capita']]
pair_plot_data['Group'] = Group
pair_plot_data.iloc[[0, 52, 104]]