7.6 scale_*_date Function
scale_x_date()
scale_y_date()
from scales
package
Main parameters: date_breaks()
labels = date_format()
date_breaks() is used to set the positions of the tick marks on the x-axis of a plot
date_breaks() function takes one argument, which is the unit of time
For example, we can use date_breaks() like this
date_breaks(“1 year”)
date_breaks(“6 months”)
date_breaks(“1 week”)
date_breaks(“10 days”)
- date_format() function takes a single argument, which is a string that specifies the desired format of the date
For example,
date_format(“%Y-%m-%d”): YYYY-MM-DD
date_format(“%Y”): YYYY
date_format(“%B”): Full month name (January, February, etc.)
date_format(“%b”): Abbreviated month name (Jan, Feb, etc.)
date_format(“%d”): Two-digit day of the month (01, 02, …, 30, 31)
date_format(“%A”): Full weekday name (Sunday, Monday, Tuesday, etc.)
date_format(“%a”): Abbreviated weekday name (Sun, Mon, Tue, etc.)
more info: