# Create Example data
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)
# Plot with default options
plot_chronochrt(chrons)
# Add labels
labels <- data.frame(region = "A",
year = -50,
position = 0.5,
label = "Event")
images <- data.frame(region = "B",
year = 100,
position = 0.5,
image_path = "https://www.r-project.org/logo/Rlogo.png")
plot_chronochrt(chrons, labels, images)
# Customise plot
plot_chronochrt(chrons, axis_title = "BC/AD", year_lim = c(-50,100),
fill_chron = "black", color_chron = "white", size_line = 5)
plot_chronochrt(chrons, labels, images, color_label = "red", size_text = 5,
height_image = 4)
# Export plot
file <- tempfile(fileext = ".jpg")
plot_chronochrt(chrons, filename = tempfile(fileext = ".jpg"),
plot_dim = c(10, 15, "cm"))
# with additional parameters
plot_chronochrt(chrons, filename = tempfile(fileext = ".jpg"),
plot_dim = c(10, 15, "cm"), dpi = 300)
unlink(file)
# Additional customisation with ggplot2
plot_chronochrt(chrons) + ggplot2::theme_bw()
Run the code above in your browser using DataLab