I have the following code where parameter1, 2, and alpha_values take decimal values. I wanna use heatmap but for axes, I am going to use integer values. However, when I add values for ticks in x-axis, I face the following figure. I am wondering how I should set customized ticks and also reverse the order of values in y-axis such that the maximum value is on top and the smallest value is on the bottom.
[![enter image description here][1]][1]
import matplotlib.colors as mcolors
# Create a DataFrame to store the data
data = pd.DataFrame({
r'$a$': np.round(parameter1,2),
r'$mathbb{E}(S)$': np.round(parameter2,2),
'alpha_values': alpha_values
})
# Pivot the DataFrame to create a matrix suitable for a heatmap
heatmap_data = data.pivot(index=r'$a$', columns=r'$mathbb{E}(S)$', values='alpha_values')
cmap = mcolors.LinearSegmentedColormap.from_list("gray_scale", ["white", "blue"])
x_axis_labels = np.arange(-4, 13, 2)
xticklabels = [str(c) for c in x_axis_labels]
y_axis_labels = np.arange(0, 13, 2)
ax = sns.heatmap(heatmap_data, cmap=cmap, annot=False, fmt=".2f", vmin=0, vmax=1, xticklabels=xticklabels)
#ax.set_yticklabels(yticks[::-1]) # Reverse the y-axis labels
# Add a frame around the figure
for _, spine in ax.spines.items():
spine.set_visible(True)
spine.set_linewidth(1)
'''
[1]: https://i.sstatic.net/IYKNcAFW.png