Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legend Background #28

Open
msgoussi opened this issue Sep 26, 2023 · 3 comments
Open

Legend Background #28

msgoussi opened this issue Sep 26, 2023 · 3 comments

Comments

@msgoussi
Copy link

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!

@mschilli87
Copy link

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

@msgoussi
Copy link
Author

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

@mschilli87
Copy link

mschilli87 commented Sep 27, 2023

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"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants