CodePudding user response:
Is this what you are aiming for? Note how I moved the xlabel and ylabel generation after the sn.heatmap
call.
import seaborn as sn
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams["font.family"] = "Times New Roman"
array = [[-45,-45,-46,-47,-48,-49,-48,-50,-52,-51,-53,-54,-56,-58,-57],
[-44,-45,-47,-48,-49,-48,-48,-51,-50,-52,-54,-54,-56,-58,-57],
[-45,-46,-48,-47,-50,-50,-49,-50,-52,-51,-53,-54,-56,-58,-56],
[-46,-48,-47,-47,-51,-50,-48,-50,-49,-50,-52,-53,-54,-54,-55],
[-47,-50,-49,-47,-49,-49,-48,-50,-52,-51,-53,-54,-56,-56,-55],
[-48,-51,-49,-49,-50,-51,-50,-52,-53,-51,-52,-52,-52,-57,-56],
[-47,-52,-47,-50,-48,-49,-48,-50,-52,-51,-53,-52,-50,-54,-53],
[-47,-49,-48,-49,-47,-48,-47,-49,-50,-50,-51,-52,-54,-55,-54],
[-49,-48,-47,-48,-47,-49,-48,-50,-51,-51,-53,-52,-53,-55,-53],
[-50,-48,-48,-47,-49,-50,-48,-49,-52,-52,-53,-54,-51,-58,-55],
[-52,-49,-49,-51,-48,-51,-48,-50,-53,-53,-53,-51,-52,-57,-54],
[-53,-51,-49,-51,-50,-51,-49,-52,-53,-54,-53,-53,-52,-56,-55],
[-51,-50,-51,-50,-51,-52,-50,-53,-54,-52,-53,-53,-54,-54,-53],
[-52,-52,-52,-53,-52,-54,-53,-56,-55,-53,-52,-54,-53,-55,-53],
[-54,-53,-53,-52,-54,-55,-56,-56,-54,-53,-53,-54,-56,-58,-54]]
labels = [0.45, 0.90, 1.35, 1.80, 2.25, 2.70, 3.15, 3.60, 4.05, 4.50, 4.95, 5.40, 5.85, 6.30, 6.75]
df_cm = pd.DataFrame(array, index = labels,
columns = labels)
plt.figure(figsize = (10,7))
plt.title('AP1')
sn.heatmap(df_cm, annot=False)
plt.xlabel('x(m)')
plt.ylabel('y(m)')
plt.savefig('heatmap.png')
plt.savefig('heatmap.pdf')