calendR icon indicating copy to clipboard operation
calendR copied to clipboard

Legend Background

Open msgoussi opened this issue 2 years ago • 3 comments

imp.dates <- rep(NA, 366) imp.dates[c(1, 50, 12, 125, 80, 99, 102, 205, 266, 360)] <- "special"

calendR(year = 2020, # Year mbg.col = 2, # Background color for the month names months.col = "white", # Text color of the month names special.days = imp.dates, special.col = "pink", # Color of the special.days months.pos = 0.5, bg.col = "#dbd4cc", legend.pos = "left" )

I am wondering how to color the bg color of legend!

msgoussi avatar Sep 26 '23 06:09 msgoussi

Could you add a screenshot of what you get and a modified one showing what you'd like to get instead?

mschilli87 avatar Sep 26 '23 12:09 mschilli87

if I run the above code, the background of the legend is white. so I am wondering how to change the legend's bg. Rplot

msgoussi avatar Sep 27 '23 03:09 msgoussi

library(calendR)
library(ggplot2)

imp.dates <- rep(NA, 366)
imp.dates[c(1, 50, 12, 125, 80, 99, 102, 205, 266, 360)] <- "special"

calendR(year = 2020, # Year
mbg.col = 2, # Background color for the month names
months.col = "white", # Text color of the month names
special.days = imp.dates,
special.col = "pink", # Color of the special.days
months.pos = 0.5,
bg.col = "#dbd4cc",
legend.pos = "left"
) + theme(legend.background = element_blank())

or

imp.dates <- rep(NA, 366)
imp.dates[c(1, 50, 12, 125, 80, 99, 102, 205, 266, 360)] <- "special"

calendR::calendR(year = 2020, # Year
mbg.col = 2, # Background color for the month names
months.col = "white", # Text color of the month names
special.days = imp.dates,
special.col = "pink", # Color of the special.days
months.pos = 0.5,
bg.col = "#dbd4cc",
legend.pos = "left"
) + ggplot2::theme(legend.background = ggplot2::element_blank())

edit: The above examples remove the background entirely. If you want to change the color, replace element_blank by element_rect:

library(calendR)
library(ggplot2)

imp.dates <- rep(NA, 366)
imp.dates[c(1, 50, 12, 125, 80, 99, 102, 205, 266, 360)] <- "special"

calendR(year = 2020, # Year
mbg.col = 2, # Background color for the month names
months.col = "white", # Text color of the month names
special.days = imp.dates,
special.col = "pink", # Color of the special.days
months.pos = 0.5,
bg.col = "#dbd4cc",
legend.pos = "left"
) + theme(legend.background = element_rect(fill = "lavender"))

or

imp.dates <- rep(NA, 366)
imp.dates[c(1, 50, 12, 125, 80, 99, 102, 205, 266, 360)] <- "special"

calendR::calendR(year = 2020, # Year
mbg.col = 2, # Background color for the month names
months.col = "white", # Text color of the month names
special.days = imp.dates,
special.col = "pink", # Color of the special.days
months.pos = 0.5,
bg.col = "#dbd4cc",
legend.pos = "left"
) + ggplot2::theme(legend.background = ggplot2::element_rect(fill = "lavender"))

mschilli87 avatar Sep 27 '23 10:09 mschilli87