Nothing
.plot_hexbin <- function(drhex,
colour_by = "Cluster_majority",
colors = NULL,
title = NULL,
xlab = NULL,
ylab = NULL) {
if (any(!c("x", "y", colour_by) %in% colnames(drhex))) {
stop("The dataframe must contain columns named 'x', 'y' and label.")
}
if (is.null(title)) {
title <- colour_by
}
if (is.null(xlab)) {
xlab <- "x"
}
if (is.null(ylab)) {
ylab <- "y"
}
if (grepl("majority", colour_by)) {
if (is.null(colors)) {
ggplot(drhex, aes_string("x", "y", fill = colour_by)) +
geom_hex(stat = "identity") +
theme_classic() + theme(legend.position = "bottom") +
ggtitle(title) +
labs(x = xlab, y = ylab) + theme(legend.title = element_blank())
} else {
ggplot(drhex, aes_string("x", "y", fill = colour_by)) +
geom_hex(stat = "identity") + scale_fill_manual(values = colors) +
theme_classic() + theme(legend.position = "bottom") +
ggtitle(title) +
labs(x = xlab, y = ylab) + theme(legend.title = element_blank())
}
} else {
ggplot(drhex, aes_string("x", "y", fill = colour_by)) +
geom_hex(stat = "identity") +
theme_classic() + scale_fill_viridis_c() + ggtitle(title) +
labs(x = xlab, y = ylab) + theme(legend.title = element_blank())
}
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.