import numpy as np
import matplotlib.pyplot as plt
# Define data
data = np.random.rand(5, 5)
# Create heatmap using Matplotlib
fig, ax = plt.subplots(figsize=(8, 6))
im = ax.imshow(data, cmap='coolwarm', vmin=0, vmax=1, extent=[-0.5, 4.5, -0.5, 4.5])
# Add color bar
cbar = ax.figure.colorbar(im, ax=ax, fraction=0.046, pad=0.04)
# Set title and axis labels
ax.set_title("Customized Heatmap")
ax.set_xlabel("X-axis Label")
ax.set_ylabel("Y-axis Label")
# Add annotations
for i in range(5):
for j in range(5):
text = ax.text(j, i, round(data[i, j], 2), ha="center", va="center", color="w")
# Mask certain cells
data[1, 3] = np.nan
# Show plot
plt.show()