I am confused as to have ggplot selects colors. In particular, how do I get the same color across different types of graphs. Early in my code I define
colorscheme = scale_fill_brewer(type="qual",palette = 3)
theme.noframe = theme(panel.background = element_rect(fill = 'transparent'),
legend.key=element_rect(fill='transparent'),
legend.title=element_blank(),
axis.line = element_line(color="black",linetype="solid"),
axis.text.x = element_text(color = 'black'),
axis.text.y = element_text(color='black'),
axis.title.x = element_text(colour = 'black'),
axis.title.y = element_text(colour = 'black'))
Later I have the following
ggplot(df, aes(x=Date, y=value/Divisor, fill=Fill)) +
geom_area(position="stack") + xlab("") + theme.noframe + colorscheme +
scale_x_date( labels=date_format("%Y"),breaks = date.seq ) +
ylab(paste("AUM (",LabelScale,")"))
which produces
http://rpubs.com/ramachr/154592
Then I call
ggplot(df, aes(x=Date, y=value/Divisor, color=Fill)) +
geom_line() + xlab("") + theme.noframe + colorscheme +
scale_x_date( labels=date_format("%Y"),breaks = date.seq ) +
ylab(paste("AUM (",LabelScale,")"))
I then get this
http://rpubs.com/ramachr/154597
The two differences between the calls is 1) geom_line replaces geom_area and 2) color=Fill replaces fill=Fill.
You will notice that for every category, the line colors are different from the area colors. How can I change either 'ggplot' call to make the color consistent?
scale_color_*
andscale_fill_*
set ofggplot
functions. You will likely be using thevalues
parameter in these functions. This link may be helpful cookbook-r.com/Graphs/Colors_(ggplot2) – steveb