Hi everyone,
I want my legend to show from the most to the less and can't seem to change the order of the variables.
here is my code
calendR(start_date = "2020-04-01",
end_date = "2020-04-30",
start = "S",
orientation = "portrait",
title = "Bike Ride Popularity",
title.size = 24,
title.col = tblCol[12],
col = tblCol[4],
bg.col = tblCol[3],
mbg.col = tblCol[10],
months.col = tblCol[3],
weeknames.col = tblCol[12],
weeknames.size = 6,
special.days = unlist(df_Agg_Popular_Date_Calendar %>%
dplyr::arrange(Day) %>%
dplyr::select(Part)),
special.col = c(tblCol[8],
tblCol[10],
tblCol[12],
tblCol[14]
)[order(c("Low",
"Uncommon",
"Common",
"High"))],
low.col = tblCol[8],
days.col = tblCol[3],
day.size = 4,
legend.pos = "bottom",
legend.title = "Population"
) +
theme(legend.background = element_rect(fill = tblCol[4]),
legend.key = element_rect(fill = tblCol[4]),
legend.text = element_text(color = tblCol[22]),
legend.title = element_text(color = tblCol[22])
)
When I try to put this before my code
df_Agg_Popular_Date_Calendar$Part <- factor(df_Agg_Popular_Date_Calendar$Part,
levels = c("Low",
"Uncommon",
"Common",
"High"))
a new error comes up:
"Error in if (any(special.days > length(dates))) { :
Missing value where TRUE/FALSE needed "
The code works without factor but the legend isn't ordered properly.
There is also that white frame around inside the image I can't remove I tried
theme(rect = element_rect(fill = NA),
aspect.ratio = 0.37)
but both don't resolve it and am not sure how to approach that as a dark mode user.