Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8157313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:14:22+00:00 2026-06-06T17:14:22+00:00

I am trying to change the colours on a ggplot column chart. After googling,

  • 0

I am trying to change the colours on a ggplot column chart. After googling, I thought that the following code would work:

require(ggplot2)
require(RColorBrewer)
State <- c(rep("NSWTC",5), rep("TCV",5), rep("QTC",5), 
           rep("WATC",5), rep("SAFA",5), rep("Other",5))

Year  <- rep(c("11-12","12-13","13-14","14-15","15-16"),6)

##some random data
Funding.Programme <- abs(rnorm(30))

df <- data.frame(State, Year, Funding.Programme)

##this line makes the graph in the order you inputted it, rather than alphabetical
df$State <- factor(df$State, levels=unique(df$State))

##ugly coloured
bars <- 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 <- brewer.pal(5, "Blues")
blues <- rev(blues)
##the following two graphs have the same colours
bars <- 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 <- 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 <- 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

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:14:24+00:00Added an answer on June 6, 2026 at 5:14 pm

    You want scale_fill_manual(values = blues) or conversely with blues.rev (which you didn’t actually create in your example code, which I assume is a typo).

    Only use scale_*_brewer when you’re selecting one of the default palette’s by name. Otherwise, use scale_*_manual for this sort of thing.

    The last one doesn’t work because you were using colour instead of fill.

    Finally, carriage returns and tabs: love them, cherish them, use them!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code i am trying to change the font of a
I am trying to change the colours of my histogram, but not sure how
I have a LineSeries that I am trying to build from the code rather
I'm trying to write a Greasemonkey script to change colours on the default GMail
I'm trying to change the color on a white marker image by code. I
I am trying to change the default font colour of the following StyledTextCtrl, I've
I'm trying to change my nav bar's title programmatically but the code I'm using
I'm trying to get the background colors of the strips to change (it is
I'm trying change an input mask for textbox when the the check box has
Am trying to change the button frame according to the orientation change but button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.