i'm going to trying to do a heatmap from a file that has 3 columns, The format of my data is:
1 3 65.0987
2 9 49.34
5 7 0.00056
. . .
. . .
3 1 65.0987 etc..
but I've separated it in 3 files. So I'm using the next code:
from numpy import *
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
with open("1.txt") as f:
lstx = [int(x) for x in f.read().split()]
with open("2.txt") as f:
lsty = [int(x) for x in f.read().split()]
with open("3.txt") as f:
lstz = [float(x) for x in f.read().split()]
x=np.array(lstx)
y=np.array(lsty)
z=np.array(lstz)
df = pd.DataFrame.from_dict(np.array([y,x,z]).T)
df.columns = ['X_value','Y_value','Z_value']
df['Z_value'] = pd.to_numeric(df['Z_value'])
pivotted= df.pivot('Y_value','X_value','Z_value')
sns.heatmap(pivotted,cmap='Paired')
plt.show()
It works, and have this heatmap:
I want to change the format of y axis, I mean, that the number 45 is up, and 1 is low. And want too, the both axes format are without point and decimals, i mean, the numbers are 1, 3, 45, etc., instead of 1.0, 3.0, etc.
I've tried with ylim, xlim, and xticks, yticks, but doesn't work good, the out of figure is distorsionated.
Can you help me please? Have you some idea what i must to change or add to my code? Thanks for your support.