Preview:
library(ggplot2)
library(reshape2)

# Reshape data into long format for heatmap
df_long <- melt(df, id.vars = "Year", variable.name = "Month", value.name = "Temperature")

# Create the heatmap
ggplot(df_long, aes(x = Year, y = Month, fill = Temperature)) +
  geom_tile() +  # Creates the heatmap
  scale_fill_viridis_c(option = "plasma", name = "Temperature (°C)") +  # Adjust color scale
  labs(title = "Heatmap of Monthly Temperature Trends",
       x = "Year",
       y = "Month") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1))  # Rotate x-axis labels
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter