colors.100 = c("#000000", "#0089A3", "#1CE6FF", "#FF34FF", "#FF4A46", "#008941",
"#006FA6", "#A30059", "#FFDBE5", "#7A4900", "#0000A6", "#63FFAC",
"#B79762", "#004D43", "#8FB0FF", "#997D87", "#5A0007", "#809693",
"#FEFFE6", "#1B4400", "#4FC601", "#3B5DFF", "#4A3B53", "#FF2F80",
"#61615A", "#BA0900", "#6B7900", "#00C2A0", "#FFAA92", "#FF90C9",
"#B903AA", "#D16100", "#DDEFFF", "#000035", "#7B4F4B", "#A1C299",
"#300018", "#0AA6D8", "#013349", "#00846F", "#372101", "#FFB500",
"#C2FFED", "#A079BF", "#CC0744", "#C0B9B2", "#C2FF99", "#001E09",
"#00489C", "#6F0062", "#0CBD66", "#EEC3FF", "#456D75", "#B77B68",
"#7A87A1", "#788D66", "#885578", "#FAD09F", "#FF8A9A", "#D157A0",
"#BEC459", "#456648", "#0086ED", "#886F4C", "#34362D", "#B4A8BD",
"#00A6AA", "#452C2C", "#636375", "#A3C8C9", "#FF913F", "#938A81",
"#575329", "#00FECF", "#B05B6F", "#8CD0FF", "#3B9700", "#04F757",
"#C8A1A1", "#1E6E00", "#7900D7", "#A77500", "#6367A9", "#A05837",
"#6B002C", "#772600", "#D790FF", "#9B9700", "#549E79", "#FFF69F",
"#201625", "#72418F", "#BC23FF", "#99ADC0", "#3A2465", "#922329",
"#5B4534", "#FDE8DC", "#404E55", "#FFFF00")
# Don't use this function to visualize more than 42 colors!
make.color.bar.plot = function(color.vector, number.vector, title, xlab = "") {
bp = barplot(rep(1,length(color.vector)), col = color.vector,
axes = FALSE, xlab = xlab, main = title, border = NA)
axis(1, bp, number.vector)
}
# `densities` is a list, each element holding the results from executing
# the `density` function to a (different) vector
make.multiple.density.plot =
function(densities, legend.title, title, x.axis.label, legend.size = 1) {
stopifnot(length(densities) <= 100)
# take colors from the 100 distict color set
color.palette = colors.100[1:length(densities)]
plot(NA, xlim = range(sapply(densities, "[", "x")),
ylim = range(sapply(densities, "[", "y")),
main = title, xlab = x.axis.label, ylab = "Density")
mapply(lines, densities, col = color.palette)
legend("topright", legend = names(densities), fill = color.palette,
title = legend.title, cex = legend.size)
}
# `file.format` can be one of: {pdf, svg, png, tiff}
plot.string.to.file = function(file, file.format, plot.string){
if (file.format == "pdf")
pdf(file)
else if (file.format == "svg")
svg(file, width = 7, height = 7)
else if (file.format == "png")
png(file, width = 7, height = 7, units = 'in', res = 300)
else if (file.format == "tiff")
tiff(file, width = 7, height = 7, units = 'in', res = 300)
eval(parse(text = plot.string))
dev.off()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.