解释:Monthly and yearly calendars
Create ready to print monthly and yearly calendars. The function allows personalizing colors (even setting a gradient color scale for a full month or year), texts and fonts. In addition, for monthly calendars you can also add text on the days.
具体应用:
安装:
install.packages("calendR") #直接install安装包
导入:
library(calendR)
calendR() # 默认为当前年份
image.png
显示制定年份:
calendR(2021) # 显示2021
image.png
获得2021的从周一开始的日历:
calendR(year = 2021, start = "M")
image.png
对一些特定日期进行标注:即一年的1和10日进行标注。
calendR(year = 2021,
start = "M",
special.days = c(1, 10),
special.col = "lightgreen", # Color of the specified days
low.col = "white") # Background color of the rest of the days
image.png
如果需要阅历,则只需要在年份后加上月份,比如显示2021年4月并且标注1和10日:
calendR(year = 2021, month =4,
special.days = c(1, 10 ),
special.col = "lightgreen",
low.col = "white")
image.png
加入标题(如:第几年几月份):
calendR(year = 2021, month =4,
special.days = c(1, 10 ),
special.col = "lightgreen",
low.col = "white",title = "2021-04")
image.png
更多可以调试的参数可以参照下文函数解释与介绍!
整合函数的内容与解释:
函数内容
calendR(
year = format(Sys.Date(), "%Y"),
month = NULL,
start_date = NULL,
end_date = NULL,
start = c("S", "M"),
orientation = c("portrait", "landscape"),
title,
title.size = 20,
title.col = "gray30",
subtitle = "",
subtitle.size = 10,
subtitle.col = "gray30",
text = "",
text.pos = NULL,
text.size = 4,
text.col = "gray30",
special.days = NULL,
special.col = "gray90",
gradient = FALSE,
low.col = "white",
col = "gray30",
lwd = 0.5,
lty = 1,
font.family = "sans",
font.style = "plain",
day.size = 3,
days.col = "gray30",
weeknames,
weeknames.col = "gray30",
weeknames.size = 4.5,
months.size = 10,
months.col = "gray30",
months.pos = 0.5,
mbg.col = "white",
legend.pos = "none",
legend.title = "",
bg.col = "white",
bg.img = "",
margin = 1,
lunar = FALSE,
lunar.col = "gray60",
lunar.size = 7,
pdf = FALSE,
doc_name = "",
papersize = "A4"
)
函数内容对应的解释
Arguments
year
Calendar year. By default uses the current year.
month
Month of the year or NULL (default) for the yearly calendar.
start_date
Custom start date of the calendar. If start_date != NULL, year and month arguments won't be taken into account.
end_date
Custom end date of the calendar.
start
"S" (default) for starting the week on Sunday or "M" for starting the week on Monday.
orientation
The calendar orientation: "portrait" or "landscape" (default). Also accepts "p" and "l".
title
Title of the the calendar. If not supplied is the year and the month, or the year if month = NULL.
title.size
Size of the main title.
title.col
Color of the main title.
subtitle
Subtitle of the calendar in italics (optional).
subtitle.size
Font size of the subtitle.
subtitle.col
Color of the subtitle.
text
Character vector of texts to be added on the calendar. Only for monthly calendars.
text.pos
Numeric vector containing the number of days of the month where to add the texts of the text argument.
text.size
Font size of the texts added with the text argument.
text.col
Color of the texts added with the text argument.
special.days
Numeric vector indicating the days to color or "weekend" for coloring all the weekends.
special.col
Color for the days indicated in special.days. If gradient = TRUE, is the higher color of the gradient.
gradient
Boolean. If special.days is a numeric vector of the length of the displayed days, gradient = TRUE creates a gradient of the special.col on the calendar.
low.col
If gradient = TRUE, is the lower color of the gradient. If gradient = FALSE is the background color of the days. Defaults to "white".
col
Color of the lines of the calendar.
lwd
Line width of the calendar.
lty
Line type of the calendar. If lty = 0 no lines are drawn.
font.family
Font family of all the texts.
font.style
Style of all the texts and numbers except the subtitle. Possible options are "plain" (default), "bold", "italic" and "bold.italic".
day.size
Font size of the number of the days.
days.col
Color of the number of the days.
weeknames
Character vector with the names of the days of the week starting on Monday. By default they will be in the system locale.
weeknames.col
Color of the names of the days.
weeknames.size
Size of the names of the days.
months.size
Font size of the names of the months.
months.col
If month = NULL, is the color of the month names.
months.pos
Horizontal align of the month names. Defaults to 0.5 (center).
mbg.col
Background color of the month names. Defaults to "white".
legend.pos
If gradient = TRUE, is the position of the legend. It can be set to "none" (default), "top", "bottom", "left" and "right".
legend.title
If legend.pos != "none" and gradient = TRUE, is the title of the legend.
bg.col
Background color of the calendar. Defaults to "white".
bg.img
Character string containing the URL or the local directory of a image to be used as background.
margin
Numeric. Allows controlling the margin of the calendar.
lunar
Boolean. If TRUE, draws the lunar phases. Only available for monthly calendars.
lunar.col
If lunar = TRUE, is the color of the hide part of the moons.
lunar.size
If lunar = TRUE, is the size of the representation of the moons.
Boolean. If TRUE, saves the calendar in the working directory in A4 format.
doc_name
If pdf = TRUE, is the name of the generated file (without the file extension). If not specified, creates files of the format: Calendar_year.pdf for yearly calendars and Calendar_month_year.pdf for monthly calendars.
papersize
PDF paper size. Possible options are "A6", "A5", "A4" (default), "A3", "A2", "A1" and "A0". Depending on the size you will need to fine-tune some arguments, like the font sizes.
我自己的个性化日历:
calendR(year = 2021,start = "M",
special.days = c(93, 140,236 ),days.col = "black",
special.col = "green",weeknames.col = 'black',weeknames.size = 3,
months.size = 10, months.col = "black",mbg.col= 'lightblue',font.style='bold', months.pos = 0.5, lty = 0 , title = "Rashidin's 2021 Calendar",title.size =18, bg.col = "#f4f4f4", orientation = "p" )
得到:
image.png