Open msgoussi opened 1 year ago
Could you add a screenshot of what you get and a modified one showing what you'd like to get instead?
if I run the above code, the background of the legend is white. so I am wondering how to change the legend's bg.
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"))
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!