ggplot for heatmap 30km

PHOTO EMBED

Thu Jan 30 2025 12:31:23 GMT+0000 (Coordinated Universal Time)

Saved by @Rehbar #python

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
content_copyCOPY