Note that there are some explanatory texts on larger screens.

plurals
  1. POggplot column chart - order of colours in brewer object has no effect
    primarykey
    data
    text
    <p>I am trying to change the colours on a ggplot column chart. After googling, I thought that the following code would work:</p> <pre><code>require(ggplot2) require(RColorBrewer) State &lt;- c(rep("NSWTC",5), rep("TCV",5), rep("QTC",5), rep("WATC",5), rep("SAFA",5), rep("Other",5)) Year &lt;- rep(c("11-12","12-13","13-14","14-15","15-16"),6) ##some random data Funding.Programme &lt;- abs(rnorm(30)) df &lt;- data.frame(State, Year, Funding.Programme) ##this line makes the graph in the order you inputted it, rather than alphabetical df$State &lt;- factor(df$State, levels=unique(df$State)) ##ugly coloured bars &lt;- ggplot(df) + aes(x=Year ,y=Funding.Programme, fill=Year) + geom_bar(stat='identity') + facet_grid(facets=~State) + scale_y_continuous('Gross Issuance Requirements') ##nicely coloured blues &lt;- brewer.pal(5, "Blues") blues &lt;- rev(blues) ##the following two graphs have the same colours bars &lt;- ggplot(df) + aes(x=Year ,y=Funding.Programme, fill=Year) + geom_bar(stat='identity') + facet_grid(facets=~State) + scale_y_continuous('Gross Issuance Requirements') + scale_fill_brewer(blues) bars bars &lt;- ggplot(df) + aes(x=Year ,y=Funding.Programme, fill=Year) + geom_bar(stat='identity') + facet_grid(facets=~State) + scale_y_continuous('Gross Issuance Requirements') + scale_fill_brewer(blues.rev) bars ##and this does not adjust the default colours bars &lt;- ggplot(df)+ aes(x=Year,y=Funding.Programme, fill=Year) + geom_bar(stat='identity') + facet_grid(facets=~State) + scale_y_continuous('Gross Issuance Requirements') + scale_colour_manual(values = blues.rev) bars </code></pre> <p>But the last method does not work, and the second and third-last charts produced are identical, despite the order of colours being reversed in the object.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload