0
votes

I want to make a heat map on python and the heat map I got, is tough to be interpreted. I want to either enlarge the map or get a different color palette so that it can be viewed easily.

I am working on Python and here is the code :

import seaborn as sns

import matplotlib.pyplot as plt

sns.heatmap(corr)

plt.show()

heatmap

1
You have a significantly large correlation matrix and that's the reason, the density of grid points in your figure is too large resulting in a bad resolution. You can simply enlarge the figure by using a large figure size as fig = plt.figure(figsize=(14, 14)) for example - Sheldore
<Figure size 1008x720 with 0 Axes> I get this after i code the the thing above - ojj
You asked for a larger figure. That's how you do it by specifying the figure size. I don't think the problem can be resolved by choosing a different color palette. - Sheldore

1 Answers

0
votes

Something seems to be going on with the data in your data frame. Here is my code for making a correlation matrix of the closing price of 7 bank stocks.

First, I create a data frame from many series

df_close = pd.concat([bac_close_px, c_close_px, gs_close_px, jpm_close_px,        
ms_close_px, wfc_close_px], axis=1)`

Then, I plot using matplotlib and adjust the figure size and font on the labels.

f = plt.figure(figsize=(19, 15))
plt.matshow(df_close.corr(), fignum=f.number)
plt.xticks(range(df_close.shape[1]), df_close.columns, fontsize=14,rotation=45)
plt.yticks(range(df_close.shape[1]), df_close.columns, fontsize=14)
cb = plt.colorbar()
cb.ax.tick_params(labelsize=14)
plt.title('Correlation Matrix', fontsize=16);

Link to the heatmap image