I have too many features (~100) for correlation, resulting in low resolution figure. How could I improve resolution?
sns.heatmap(Feature_corr, cbar = True, square = True, annot=False,annot_kws={'size': 15}, cmap= 'coolwarm')
Call figure
from matplotlib.pyplot
before heatmap
and set the image size with figsize
, i.e.:
from matplotlib import pyplot
pyplot.figure(figsize=(15, 15)) # width and height in inches
sns.heatmap(Feature_corr, cbar=1, square=1, annot=0, annot_kws={'size': 15}, cmap= 'coolwarm')
Using the figure parameters from Matplotlib makes it possible to modify the width, height, font size of axis labels, and dpi. Adjusting those values may help your image resolution.
Additionally, you can play with the parameter annot_kws={"size": 8}
from sns.heatmap()
to modify the values font size.
DPI represents the number of pixels per inch in the figure. Higher values of DPI improve the resolution.
corr = df2.corr() #your dataframe
sns.heatmap(corr, cmap="Blues", annot=True)
Result image without Matplotlib adjustments
import matplotlib.pyplot as plt
import seaborn as sns
corr = df2.corr() #your dataframe
# figsize=(6, 6) control width and height
# dpi = 600, I
plt.figure(figsize=(6, 6),
dpi = 600)
# parameter annot_kws={"size": 8} control corr values font size
sns.heatmap(corr, cmap="Blues", annot=True, annot_kws={"size": 8})
plt.tick_params(axis = 'x', labelsize = 12) # x font label size
plt.tick_params(axis = 'y', labelsize = 12) # y font label size
Result:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With