Create an area plot to visualize the monthly rainfall trends for each selected district
# Ensure Month is a factor with all levelsrainfall_filtered$Month <-factor( rainfall_filtered$Month,levels =c("JAN", "FEB", "MAR", "APR", "MAY", "JUN","JUL", "AUG", "SEP", "OCT", "NOV", "DEC"),ordered =TRUE)# Complete the data: fill in missing Month-DISTRICT combosrainfall_completed <- rainfall_filtered %>% tidyr::complete(DISTRICT, Month, fill =list(Rainfall =NA))scale_x_discrete(drop =FALSE)
<ggproto object: Class ScaleDiscretePosition, ScaleDiscrete, Scale, gg>
aesthetics: x xmin xmax xend
axis_order: function
break_info: function
break_positions: function
breaks: waiver
call: call
clone: function
dimension: function
drop: FALSE
expand: waiver
get_breaks: function
get_breaks_minor: function
get_labels: function
get_limits: function
get_transformation: function
guide: waiver
is_discrete: function
is_empty: function
labels: waiver
limits: NULL
make_sec_title: function
make_title: function
map: function
map_df: function
n.breaks.cache: NULL
na.translate: TRUE
na.value: NA
name: waiver
palette: function
palette.cache: NULL
position: bottom
range: environment
range_c: environment
rescale: function
reset: function
train: function
train_df: function
transform: function
transform_df: function
super: <ggproto object: Class ScaleDiscretePosition, ScaleDiscrete, Scale, gg>
ggplot(rainfall_completed, aes(x = Month, group = DISTRICT)) +geom_ribbon(aes(ymin =0, ymax = Rainfall), fill ="skyblue", alpha =0.5) +geom_line(aes(y = Rainfall), color ="black", linewidth =1) +facet_wrap(~ DISTRICT, scales ="free_x") +scale_x_discrete(drop =FALSE) +labs(title ="Monthly Rainfall Trends in Selected Indian Cities",x ="Month",y ="Rainfall (mm)" ) +theme_minimal() +theme(axis.text.x =element_text(angle =45, hjust =1))