A slightly different approach to @ilir:
dat <- data.frame(x=factor(1:10), y=1)
gg <- ggplot(dat, aes(x=x, y=y, fill=x))
gg <- gg + geom_bar(stat='identity', width=1)
gg <- gg + scale_fill_manual(values=c("#646464", "#62cd64", "#b04664", "#396164", "#f6f664", "#f5a664", "#176b64", "#00ff64", "#1c0064", "#921964"))
gg <- gg + theme_minimal()
gg <- gg + theme(legend.position='none')
gg
You need to use scale_fill_manual
vs scale_color_manual
. Also, doing the ggplot
calls this way makes it way easier to adjust the code later.
UPDATE based on your new color ramp:
dat <- data.frame(x=factor(1:19, y=1))
colors <- c("#ffffff", "#ffffff", "#ffffff", "#ffffff", "#aaaaaa", "#555555",
"#000000", "#000000", "#000000", "#000000", "#000000", "#000000",
"#000000", "#555555", "#aaaaaa", "#ffffff", "#ffffff", "#ffffff",
"#ffffff")
gg <- ggplot(dat, aes(x=x, y=y, fill=x))
gg <- gg + geom_bar(stat='identity', width=1)
gg <- gg + scale_fill_manual(values=colors)
gg <- gg + theme_minimal()
gg <- gg + theme(legend.position='none')
gg