| Title: | Plot Event Times on a 24-Hour Clock |
|---|---|
| Description: | Provides a novel visualization technique for plotting timestamped events on a 24-hour circular clock face. This is particularly useful for analyzing daily patterns, event clustering, and gaps in temporal data. The package also generalizes this approach to create cyclic charts for other periods, including weekly and monthly cycles, enabling effective event planning and pattern analysis across multiple time frames. |
| Authors: | Abdullah Al Mahmud [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-2814-8798>) |
| Maintainer: | Abdullah Al Mahmud <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.8.3 |
| Built: | 2026-05-21 07:32:58 UTC |
| Source: | https://github.com/mahmudstat/clockplot |
A dataset containing earthquakes magnitude, depth, and location information.
bdquakebdquake
A data frame with 13 rows and 5 variables:
Latitude
Longitude
Depth
Magnitude
Time
A dataset containing temperature of Dhaka, Sylhet, and Chittagong Cities.
bdtempbdtemp
A data frame with 36 rows and 3 variables:
Average monthly temperature
Month of the year
Name of the city
A dataset containing Bangladesh Railway Express Train schedule
brintcitybrintcity
A data frame with 84 rows and 10 variables:
Serial
Train No.
Train name
Type of train
The day of the week when the train does not run
The station from where the train departs
The time of departure
The station where the train is heading
The time of arrival
East/West
Bangladesh Railway
A dataset containing timings of chat by two individuals Abid and Abir The set contains 25 pushes by each individual
chatdfchatdf
A data frame with 25 rows and 3 variables:
Name of the chat participant
Time in HH:MM:SS format
Turn of the chat
Randomly generated
There are five types of clock charts, clock_chart() being the simplest one.
It just shows the event times on a 24 hour clock. The lines are neither
colored, nor length modified. clock_chart_col() is used to colorize and
clock_chart_len() to change the length of the hands by a numeric vector.
To do both simultaneously, use clock_chart_qnt(). To use a qualitative
variable as the criterion, use clock_chart_qlt().
clock_chart(data, time, Col = "black")clock_chart(data, time, Col = "black")
data |
A data frame |
time |
Time in 24 hours. The allowed time formats for these family
of charts are |
Col |
A single color name for the lines. The default is |
Change the title, subtitle or the caption of the plot with
ggplot2::labs().
A ggplot object, which can be further modified
with ggplot2 functions and themes.
clock_chart_col(), clock_chart_qnt(), and clock_chart_qlt().
p1 <- clock_chart(smsclock, time) # Using package built-in data p1 + ggplot2::labs(title = "SMS Receiving Times") # Add clock_chart(brintcity %>% filter(Origin == "Dhaka"), time = Departure)p1 <- clock_chart(smsclock, time) # Using package built-in data p1 + ggplot2::labs(title = "SMS Receiving Times") # Add clock_chart(brintcity %>% filter(Origin == "Dhaka"), time = Departure)
This function will plot time of events on a 24 hour clock to show which events took place at what times. The lines are colored by a criteria.
clock_chart_col(data, time, crit, high = "red", low = "green")clock_chart_col(data, time, crit, high = "red", low = "green")
data |
A data frame |
time |
Time in 24 hours. The allowed time formats for these family
of charts are |
crit |
a numeric vector by which lines will be colored. |
high |
The color name for the high values. The default is |
low |
The color name for the low values. The default is |
Change the title, subtitle or the caption of the plot with
ggplot2::labs() .Change the legend title by adding
ggplot2::labs(size = "TITLE") or labs(color = "TITLE").
Add
or modify legend by theme(legend.position = "POSITION"); the valid
position names in ggplot2 are top, bottom, right, and left,
excluding more complex options.
A ggplot object, which can be further modified
with ggplot2 functions and themes.
clock_chart_qnt(), and clock_chart_qlt().
df <- data.frame( time = c("06:00:00", "08:00:00", "17:30:00"), value = c(3, 6, 9) ) clock_chart_col(df, time, crit = value) + ggplot2::labs(size = "TITLE")df <- data.frame( time = c("06:00:00", "08:00:00", "17:30:00"), value = c(3, 6, 9) ) clock_chart_col(df, time, crit = value) + ggplot2::labs(size = "TITLE")
This function will plot time of events on a 24 hour clock to show which
events took place at what times. The hands are colored by a
qualitative (factor) vector.
Change the plot's title, subtitle, or caption using ggplot2::labs().
For example: ggplot2::labs(title = "My Plot", subtitle = "My Subtitle")
You can change the title of the legend by adding ggplot2::labs(color = "Legend Title").
clock_chart_qlt(data, time, crit)clock_chart_qlt(data, time, crit)
data |
A data frame |
time |
Time in 24 hours. The allowed time formats for these family
of charts are |
crit |
The qualitative vector by which hands will be colored. |
A ggplot object, which can be further modified
with ggplot2 functions and themes.
clock_chart_col() for coloring and clock_chart_qnt() for more options.
# A plot showing sms receiving times based on # criteria (type/sender/invoked) clock_chart_qlt(smsclock, time = time, crit = sender) + ggplot2::labs(color = "Sender", title = "SMS's Received throughout th Day")# A plot showing sms receiving times based on # criteria (type/sender/invoked) clock_chart_qlt(smsclock, time = time, crit = sender) + ggplot2::labs(color = "Sender", title = "SMS's Received throughout th Day")
This function will plot time of events on a 24 hour clock to show which events took place at what times. The length and color of the hands are modified according to a numeric vector.
clock_chart_qnt(data, time, len, Col = NULL, high = "red", low = "green")clock_chart_qnt(data, time, len, Col = NULL, high = "red", low = "green")
data |
A data frame |
time |
Time in 24 hours. The allowed time formats for these family
of charts are |
len |
The numeric vector by which hands will be modified and colored. |
Col |
Optional. A numeric vector to change color. This option will be discontinued. |
high |
The color name for the high values. The default is |
low |
The color name for the low values. The default is |
Change the title, subtitle or the caption of the plot with
ggplot2::labs() .Change the legend title by adding
ggplot2::labs(color = "TITLE 1", size = "TITLE2").
Add
or modify legend by theme(legend.position = "POSITION"); the valid
position names in ggplot2 are top, bottom, right, and left,
excluding more complex options.
A ggplot object, which can be further modified
with ggplot2 functions and themes.
clock_chart_col() for coloring by a numeric variable,
clock_chart_qlt() for coloring by a qualitative variable,
clock_chart() for the simplest clock chart
p1 <- clock_chart_qnt( data = bdquake, time = hms, len = depth, Col = mag, high = "red", low = "blue" ) p1 + ggplot2::labs( color = "Depth", size = "Magnitude", title = "Earthquakes in Bangladesh since 2023" )p1 <- clock_chart_qnt( data = bdquake, time = hms, len = depth, Col = mag, high = "red", low = "blue" ) p1 + ggplot2::labs( color = "Depth", size = "Magnitude", title = "Earthquakes in Bangladesh since 2023" )
This function plots values corresponding to random periods such as hours, days, months and so on.
cyclic_chart(df, Period, Value, crit, ColV)cyclic_chart(df, Period, Value, crit, ColV)
df |
A data frame |
Period |
A list of periodical values such as hours of the day, days of the week, months of the year and so on. |
Value |
A numeric vector with the values corresponding to the |
crit |
A factor variable based on which the bars would be colored. |
ColV |
A character vector with the list of colors for the bars. You can use this online tool (https://r-charts.com/color-palette-generator/) to create a beautiful color palette. |
This can plot values corresponding to multiple categories, for example, temperature in different cities on the days of a week, or rainfall by month in a year.
A ggplot object, which can be further modified
with ggplot2 functions and themes.
day_chart() for plotting values on a day by hours,
week_chart() for plotting values in a week by days,
year_chart() for plotting values in a year by months
# Using package built-in bdtemp data Col <- c("#0040ff", "#00bfff", "#8000ff") cyclic_chart(bdtemp, Period = Month, Value = Temperature, crit = City, ColV = Col )# Using package built-in bdtemp data Col <- c("#0040ff", "#00bfff", "#8000ff") cyclic_chart(bdtemp, Period = Month, Value = Temperature, crit = City, ColV = Col )
This function plots values corresponding to each hour on a rose plot.
day_chart(hvalue, high = "blue", low = "yellow", width = 0.8)day_chart(hvalue, high = "blue", low = "yellow", width = 0.8)
hvalue |
A numeric vector having values at each of 24 hours (starts from 6 am) |
high |
The color name for the high values. The default is |
low |
The color name for the low values. The default is |
width |
Width of bars |
The color names can be vice versa or other colors, depending on the context.
A ggplot object, which can be further modified
with ggplot2 functions and themes.
week_chart() for plotting values in a week by days
year_chart() for plotting values on in a year by months
cyclic_chart() for plotting values by arbitrary period
value <- sample(15:30, 24, replace = TRUE) day_chart(hvalue = value, high = "blue", low = "yellow", width = 0.8)value <- sample(15:30, 24, replace = TRUE) day_chart(hvalue = value, high = "blue", low = "yellow", width = 0.8)
A dataset containing commit information of all the commits in this
repository (clockplot) up to 12 Sep, 2024. Some columns, including the
commit message have been omitted.
gitcommitgitcommit
A data frame with 110 rows and 6 variables:
Commit ID
Day of the week
Month
Day of the month
Time–this is our desired column
Year
This function plots works corresponding to each hour on a rose plot.
plan_day(dwork, width = 1, brdcol = "grey")plan_day(dwork, width = 1, brdcol = "grey")
dwork |
A character vector of length 24, with activity names for each hour starting from 6 AM and ending at 5 AM the next day. |
width |
Width of bars. |
brdcol |
Color of bar border. Use |
A ggplot object, which can be further modified
with ggplot2 functions and themes.
set.seed(123) work <- sample(c("Study", "Adda", "Entertainment", "Games", "Exercise", "Meal"), size = 24, replace = TRUE ) plan_day(dwork = work, brdcol = NA)set.seed(123) work <- sample(c("Study", "Adda", "Entertainment", "Games", "Exercise", "Meal"), size = 24, replace = TRUE ) plan_day(dwork = work, brdcol = NA)
This function plots works corresponding to each day of the week.
plan_week(wtask)plan_week(wtask)
wtask |
A factor variable having values on each day of the week. |
A ggplot object, which can be further modified
with ggplot2 functions and themes.
set.seed(10) wtask <- c( "Desk Work", "Field Work", "Visit", "Monitoring", "Rest", "Reporting", "Meeting" ) plan_week(wtask)set.seed(10) wtask <- c( "Desk Work", "Field Work", "Visit", "Monitoring", "Rest", "Reporting", "Meeting" ) plan_week(wtask)
A dataset containing timings of receiving sms on mobile phone. Real data from 01 to 09 September, 2024
smsclocksmsclock
A data frame with 82 rows and 7 variables:
Date
Day
Time in HH:MM:SS format
Name of the sms sender
Whether the sms is invoked by the user
The category of the sms; offer, info, ad, service etc.
Message Title
Phone Messages
This function plots values corresponding to each day on a rose plot.
week_chart(wvalue, lgnm = "Value", high = "yellow", low = "green", width = 0.9)week_chart(wvalue, lgnm = "Value", high = "yellow", low = "green", width = 0.9)
wvalue |
A numeric vector having values on each day, starting from Saturday |
lgnm |
Title of legend |
high |
The color name for the high values. The default is |
low |
The color name for the low values. The default is |
width |
The width of bars. |
A ggplot object, which can be further modified
with ggplot2 functions and themes.
day_chart() for plotting values in on a day hours
year_chart() for plotting values on in a year by months
cyclic_chart() for plotting values by arbitrary period
set.seed(10) wtemp <- sample(10:40, 7) week_chart(wtemp, high = "yellow") + ggplot2::labs(title = "Random Values by Day")set.seed(10) wtemp <- sample(10:40, 7) week_chart(wtemp, high = "yellow") + ggplot2::labs(title = "Random Values by Day")
This function plots values corresponding to each month on a rose plot.
year_chart(mvalue, lgnm = "Value", width = 0.9, high = "yellow", low = "green")year_chart(mvalue, lgnm = "Value", width = 0.9, high = "yellow", low = "green")
mvalue |
A numeric vector of length 12, with values for each month (Jan–Dec).
If you have it in a data frame, extract it (e.g. |
lgnm |
Title of the legend (default |
width |
Width of bars. |
high |
Color name for high values (default |
low |
Color name for low values (default |
A ggplot object, which can be further modified with ggplot2 functions.
day_chart() for plotting values on a day by hours
week_chart() for plotting values in a week by days
cyclic_chart() for plotting values by arbitrary period
syltmp <- c(18.4, 20.8, 24.3, 26.0, 26.8, 27.6, 28.0, 28.2, 27.9, 26.7, 23.3, 19.7) year_chart(mvalue = syltmp)syltmp <- c(18.4, 20.8, 24.3, 26.0, 26.8, 27.6, 28.0, 28.2, 27.9, 26.7, 23.3, 19.7) year_chart(mvalue = syltmp)