To emphasize value differences in a bar chart, using gradient colors is a nice option. ggplot makes it easy with scale_fill_gradient2()
.
Example
# create test data
col <- c('A', 'B', 'C', 'D', 'E')
val <- c(-4, -2, 1, 3, 5)
df <- data.frame(col, val)
# create graph
ggplot(data = df, aes(x = col, y = val)) +
geom_bar(stat = 'identity', aes(fill = val)) +
scale_fill_gradient2(low='orange', mid='snow', high='blue')

low
, mid
and high
values are from a list of Predefined Color Names.
Leave a Reply