# Create the Plotly figure
p <- plot_ly(climate_data, x = ~Year, y = ~TempAnomaly,
type = 'scatter', mode = 'lines+markers',
marker = list(size = 5, color = colors[color_indices]),
line = list(color = 'rgba(100, 100, 100, 0.5)'),
hoverinfo = 'text',
text = ~paste("Year:", Year,
"<br>Temperature Anomaly:",
round(TempAnomaly, 2), "°C")) %>%
layout(title = "Global Temperature Anomalies (1880-2024)",
xaxis = list(title = "Year"),
yaxis = list(title = "Temperature Anomaly (°C)"),
hovermode = "closest")