0

Good evening.

I created a heat map using seaborn to generate a correlation graph. However, the data is with the decimal separator in the American standard (using a dot). I tried to create a function where the columns of the dataset that generated the heatmap are transformed to the string format, only that seaborn cannot generate the graph.

In short, I would like the values in the heatmap to come out with the decimal separator with "comma" instead of a dot. Does anyone know where I can find a solution to this? Grateful for the attention.

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np

p1 = pd.read_csv('P1.txt', sep =';')

cor = p1.corr()

def formatnumbers(x):
    #x = round(x, 3)
    x = str(x).replace('.', ',')
    return x

for col in cor.columns:
    cor['Prisma'] =  cor['Prisma'].apply(formatnumbers)
    cor['Alt_Prd'] =  cor['Alt_Prd'].apply(formatnumbers)
    cor['Qnt_Prd'] =  cor['Qnt_Prd'].apply(formatnumbers)
    cor['Distância'] =  cor['Distância'].apply(formatnumbers)

cor['Prisma'] = cor['Prisma'].astype('float64')

plt.figure(figsize=(7,5))
sns.set_style({'font.family':'serif', 'font.serif':'Times New Roman'})
sns.heatmap(cor,center = 0, annot = True)
sns.set(font_scale=1.15)
plt.yticks(rotation = 0)
plt.show();

enter image description here

enter image description here

0 Answers0