Generate a ggtree Plot with Colored Tips
Source:R/tourSetlistDistanceTree.R
create_ggtree_plot_colored.Rd
This function generates a ggtree plot from a given concert setlists distance tree. The tree tips are colored based on either country or leg, allowing for visual differentiation of the tips in the plot.
Usage
create_ggtree_plot_colored(
setlist_tree,
show_info,
color_by = c("country", "leg")
)
Examples
library(ggtree)
# Example tree structure (replace with actual tree object)
setlist_tree <- rtree(10) # Generate a random tree with 10 tips
show_info <- data.frame(city_date = paste("City", 1:10),
country = sample(c("USA", "Canada"), 10, replace = TRUE),
leg = sample(c("Leg 1", "Leg 2"), 10, replace = TRUE))
plot <- create_ggtree_plot_colored(setlist_tree, show_info, color_by = "country")
#> Error in element_text(size = 8): could not find function "element_text"
print(plot)
#> function (x, y, ...)
#> UseMethod("plot")
#> <bytecode: 0x56319665baf0>
#> <environment: namespace:base>