# Create example data
library(ggplot2)
chrons <- data.frame(region = c("A", "B", "B", "B", "A"),
name = c("a", "a", "1", "2", "b"),
start = c(-100, -100, -100, "0/50", "50_100"),
end = c("50_100", 150, "0/50", 150, 200),
level = c(1, 1, 2, 2, 1),
add = FALSE)
ggplot(chrons) +
geom_chronochRt(aes(name = name, region = region, level = level,
start = start, end = end, add = add))
ggplot(chrons, aes(name = name, region = region, level = level,
start = start, end = end, add = add)) +
geom_chronochRt()
# If more than one region should be plotted, they must be separated with
# facet_grid():
ggplot(chrons) +
geom_chronochRt(aes(name = name, region = region, level = level,
start = start, end = end, add = add)) +
facet_grid(cols = vars(region), scales = "free_x", space = "free_x")
# Adjust upper and lower end of a chronological chart with year_lim:
q <- ggplot(chrons, aes(name = name, region = region, level = level,
start = start, end = end, add = add)) +
facet_grid(cols = vars(region), scales = "free_x", space = "free_x")
q + geom_chronochRt(year_lim = c(-50, 100))
# Change aesthetics of the plot:
q + geom_chronochRt(fill = "black", colour = "white")
q + geom_chronochRt(aes(fill = level, size_line = 3))
# Change position of the names:
q + geom_chronochRt(aes(name_x = 0.75))
# To remove vertical lines within a chronological column:
q + geom_chronochRt(minimal = TRUE)
Run the code above in your browser using DataLab