this is the nav!

â€Œ
â€Œ
â€Œ
â€Œ
â€Œ
â€Œ
â€Œ
â€Œ
â€Œ
â€Œ
â€Œ
â€Œ
â€Œ
â€Œ
Workspace
Andy Ly/

# Market Index Diagonal Correlation Plot-Complete

0
Beta

## .mfe-app-workspace-11ezf91{display:inline-block;}.mfe-app-workspace-11ezf91:hover .Anchor__copyLink{visibility:visible;}Market index correlation with a diagonal correlation plot

```.mfe-app-workspace-11z5vno{font-family:JetBrainsMonoNL,Menlo,Monaco,'Courier New',monospace;font-size:13px;line-height:20px;}```# Load packages
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_theme(style="darkgrid")
%config InlineBackend.figure_format = 'retina'``````
``````# Upload your data as CSV and load as data frame
``````# Compute the correlation matrix
corr = df.corr(method = 'pearson')

# Generate a mask for the upper triangle

# Set up the matplotlib figure
fig, ax = plt.subplots(figsize=(11, 9))                    # Set figure size

# Generate a custom diverging colormap
cmap = sns.diverging_palette(230, 20, as_cmap=True)

# Draw the heatmap with the mask
sns.heatmap(corr,
cmap = cmap,
vmax = 1,                                      # Set scale min value
vmin = -1,                                     # Set scale min value
center = 0,                                    # Set scale min value
square = True,                                 # Ensure perfect squares
linewidths = 1.5,                              # Set linewidth between squares
cbar_kws = {"shrink": .9},                     # Set size of color bar
annot = True                                   # Include values within squares
);

plt.xticks(rotation=45)                                    # Rotate x labels
plt.yticks(rotation=45)                                    # Rotate y labels
# plt.xlabel('X Axis Title', size=20)                      # Set x axis title
# plt.ylabel('Y Axis Title', size=20)                      # Set y axis title
plt.title('Diagonal Correlation Plot', size=30, y=1.05);   # Set plot title and position``````
• AI Chat
• Code