Ready to print monthly and yearly calendars made with ggplot2
đź“… The calendars will be created by default in the system locale. Change it with Sys.setlocale(locale = "the_preferred_language")
.
đź“– Check the full calendR package tutorial.
- Installation
- Yearly calendar
- Monthly calendar
- Custom start and end date
- Start of the week
- Orientation
- Heat map
- Add several events
- Add week numbers of the year
- Add background image
- Lunar calendar
- Save as PDF
- More examples
# Install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("R-CoderDotCom/calendR")
install.packages("calendR")
library(calendR)
calendR() # Defaults to the current year
calendR(year = 2020, # Year
mbg.col = 2, # Background color for the month names
months.col = "white", # Text color of the month names
special.days = c(1, 50, 12, 125, 80, # Color days of the year
99, 102, 205, 266, 360),
special.col = "pink", # Color of the special.days
months.pos = 0.5) # Horizontal alignment of the month names
calendR(year = 2028, month = 1)
calendR(month = 7, year = 2022,
special.days = c(1, 5, 12, 28), # Color days of the month
text = "Visit\nhttps://r-coder.com/", # Add some text
text.pos = c(1, 5, 12, 28)) # Where to add the text
calendR(from = "2020-09-01", # Start date
to = "2021-05-31", # End date
lty = 0, # Line type
title = "2020-2021", # Title
start = "M", # Start on Mondays
months.pos = 0) # Left-align month names
# calendR(month = 1, start = "S") # Week starts on Sunday (default)
calendR(month = 1, start = "M") # Week starts on Monday
# calendR(year = 2021, orientation = "landscape") # Default
calendR(year = 2021, orientation = "portrait")
calendR(year = 2021, special.days = 1:365,
gradient = TRUE, # Needed to create the heat map
special.col = rgb(1, 0, 0, alpha = 0.6), # Higher color
low.col = "white") # Lower color
# Data
my_data <- runif(20, 10, 20)
# Create a vector where all the values are
# a bit lower than the lowest value of your data
# (This will make the trick)
days <- rep(min(my_data) - 0.05, 365)
# Fill the days you want with your data
days[20:39] <- my_data
calendR(year = 2021,
special.days = days,
gradient = TRUE, # Needed to create the heat map
special.col = rgb(1, 0, 0, alpha = 0.6), # Higher color
low.col = "white") # In this case, the color of the values out of the gradient
# Vector of NA which length is the number of days of the year or month
myfills <- rep(NA, 366)
# Add the events to the desired days
myfills[c(1:4, 50, 300:315)] <- "Holidays"
myfills[16] <- "Birthday"
calendR(special.days = myfills,
special.col = 2:3, # Add as many colors as events
legend.pos = "right") # Add a legend if desired
The colors are displayed based on the levels of the factor of the categorical variable.
# Current order:
levels(factor(myfills)) # "Birthday" "Holidays"
#------
# Way 1
#------
calendR(special.days = myfills,
special.col = 3:2, # Change the order to match the desired colors
legend.pos = "right")
#------
# Way 2
#------
# Desired order and colors
desired_order <- c("Holidays", # (2: red)
"Birthday") # (3: green)
# Order the colors based on the desired order
ordered_colors <- c(2, 3)[order(desired_order)]
calendR(special.days = myfills,
special.col = ordered_colors, # Ordered colors
legend.pos = "right") # Add a legend if desired
start_date <- "2020-04-01"
end_date <- "2020-12-31"
custom_dates <- seq(as.Date(start_date), as.Date(end_date), by = "1 day")
events <- rep(NA, length(custom_dates))
# Time difference
dif <- 365 - length(custom_dates)
myfills <- rep(NA, length(custom_dates))
# Specify the dates as in a 365 days calendar and substract the time difference
myfills[c(180:210) - dif] <- "Holidays"
myfills[215 - dif] <- "Birthday"
calendR(from = start_date, to = end_date,
special.days = myfills, special.col = 2:3, legend.pos = "bottom")
calendR(year = 2021,
week.number = TRUE, # Adds the week number of the year for each week
week.number.col = "gray30", # Color of the week numbers
week.number.size = 8) # Size of the week numbers
calendR(year = 2021,
month = 2,
week.number = TRUE, # Adds the week number of the year for each week
week.number.col = 2, # Color of the week numbers
week.number.size = 14) # Size of the week numbers
calendR(mbg.col = 4, # Background color for the month names
months.col = "white", # Text color of the month names
special.days = "weekend", # Color the weekends
special.col = "lightblue", # Color of the special.days
lty = 0, # Line type
weeknames = c("Mo", "Tu", # Week names
"We", "Th",
"Fr", "Sa",
"Su"),
title.size = 30, # Title size
orientation = "p", # Portrait orientation
start = "M", # Start the week on Mondays
bg.img = "https://i.pinimg.com/originals/10/1e/f6/101ef6a9e146b23de28fa2cd568ad17b.jpg") # Image
calendR(month = 1,
lunar = TRUE, # Add moons to monthly calendar
lunar.col = "gray60", # Color of the non-visible area of the moon
lunar.size = 7) # Size of the moons
# Defaults to A4 size
calendR(year = 2021, orientation = "portrait", pdf = TRUE)
# Set a paper size (from A6 to A0)
calendR(year = 2021, orientation = "portrait", pdf = TRUE, papersize = "A6")
# Specify a custom document name
calendR(year = 2021, orientation = "portrait", pdf = TRUE, doc_name = "My_calendar")
calendR(year = 2022, # Year
mbg.col = 2, # Background color for the month names
months.col = "white", # Text color of the month names
special.days = c(1, 50, 12, 125, 80, # Color days of the year
99, 102, 205, 266, 359),
special.col = "pink", # Color of the special.days
months.pos = 0.5, # Center the month names
lty = 0, # Line type
weeknames = c("Mo", "Tu", "We", "Th", # Week names
"Fr", "Sa","Su"),
bg.col = "#f4f4f4", # Background color
title.size = 60, # Title size
orientation = "p") # Orientation
calendR(year = 2020, # Year
month = 10, # Month
title = "My calendar", # Change the title
subtitle = "Have a nice day", # Add a subtitle (or motivational phrase)
subtitle.col = 3, # Color of the subtitle
weeknames = c("S", "M", "T", "W", # Change week day names
"T", "F", "S"),
bg.col = "white", # Background color
special.days = "weekend", # Colorize the weekends (you can also set a vector of days)
special.col = rgb(0, 0, 1, 0.15), # Color of the special days
text = "Running", # Add text (only for monthly calendars)
text.pos = c(7, 14, 25)) # Days of the month where to put the texts
calendR(from = "2020-09-01", # Custom start date
to = "2021-05-31", # Custom end date
mbg.col = 4, # Background color for the month names
months.col = "white", # Text color of the month names
special.days = "weekend", # Color the weekends
special.col = "lightblue", # Color of the special.days
lty = 0, # Line type
weeknames = c("Mo", "Tu", # Week names
"We", "Th",
"Fr", "Sa",
"Su"),
bg.col = "#f4f4f4", # Background color
title = "Academic calendar 2020-2021", # Title
title.size = 30, # Title size
orientation = "p", # Portrait orientation
start = "M") # Start of the week
# See all the arguments of the function for full customization of the colors, text size and style.
Sys.setlocale(locale = "English")
calendR(month = 10, # Month
start = "M", # Week starts on Monday
orientation = "landscape", # Horizontal
# Size and color of the title
title.size = 40,
title.col = "white",
weeknames = c("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"),
# Subtitle, color y and size
subtitle = "I WITCH YOU A HAPPY HALLOWEEN",
subtitle.col = "red",
subtitle.size = 16,
# Text, color, size and position
text = "HALLOWEEN",
text.col = "red",
text.size = 5,
text.pos = 31,
# Color the weekends with gray
special.days = "weekend",
special.col = "grey40",
# Color of the lines, of the background
# and of the days
col = "white",
bg.col = "grey20",
low.col = "transparent", # The same color as the background
# Color and size of the number of the days
days.col = "white",
day.size = 4,
# Moon phases and moon sizes
lunar = TRUE,
lunar.size = 8,
lunar.col = "red",
# Color and size of the week names
weeknames.col = "white",
weeknames.size = 6,
# Width and line types
lwd = 0.25,
lty = 1,
# Background image
bg.img = "https://user-images.githubusercontent.com/67192157/94996404-cdc5cd80-05a4-11eb-97cb-84a195d9138c.png",
# Font family and font styles
font.family = "CF Halloween", # You will need to download and import the font with the extrafont package
font.style = "plain",
pdf = TRUE,
doc_name = "halloween")