[R] Σχετ: change colour in barplot

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Mon Nov 20 15:47:12 CET 2017

Just so you know, your attachments were stripped on the mailing list both times. It was your direct cc to Duncan that allowed him to see your attachments. Please avoid using attachments in the future, and if you must anyway then read the Posting Guide about which MIME type attachments are allowed so others can contribute to the discussion and benefit from the exchange you do have. (You can verify how your email/attachments came through by reading it on the mailing list archives.)
Sent from my phone. Please excuse my brevity.

On November 20, 2017 4:09:34 AM PST, Maria Lathouri via R-help <r-help at r-project.org> wrote:
>Dear all, 
>I am really sorry for this. I have attached the script and a .csv file
>with an example. 
>Hope this will help.
>Many thanks,Maria 
>Στις 11:53 π.μ. Δευτέρα, 20 Νοεμβρίου 2017, ο/η Duncan Murdoch
><murdoch.duncan at gmail.com> έγραψε:
> On 20/11/2017 6:38 AM, Maria Lathouri via R-help wrote:
>>  Dear all
>> I know that it is a very simple question but it seems that I cannot
>change the colour in the bars.
>> I have the following dataframe:
>> A                  B                 C           D          E        
>           F                    G                0.0.24          152460
>        474       5.5        612000           59061000       1540313
>> and here is the script:
>> setwd("~/Desktop")
>> emission<-read.csv("emission from land.csv")
>> attach(emission)
>> #define the formulas
>> #combine my outputs into a new dataframe
>> dat<-cbind(Emission_from_Land, Emission_from_Access_Road,
>> #plot a barplot
>> barplot(dat, ylab="Kg-CO2 Eq", ylim=c(0.0e+00, 2e+10),
>axisnames=FALSE, col=c("blue", "red", "orange"),
>>          main ="Well Site Construction Emissions",
>legend.text=c("Land", "Access", "Well"),
>>          args.legend = list(x="bottom", horiz="TRUE", bty="n",
>inset=c(-0.5, -0.25)))
>> When I add the col= argument, the colour changes in the legend but
>not the actual bars in the plot. I don't know what I am doing wrong. I
>know that I am missing something but I cannot figure it out.
>> I would very much appreciate for your help.
>We don't have your data, so we can't reproduce that plot.  But when I
>the following, I see three colours:
>dat <- matrix(1:9, ncol=3)*0.5e9
>barplot(dat, ylab="Kg-CO2 Eq", ylim=c(0.0e+00, 2e+10), axisnames=FALSE,
>col=c("blue", "red", "orange"),
>          main ="Well Site Construction Emissions", 
>legend.text=c("Land", "Access", "Well"),
>          args.legend = list(x="bottom", horiz="TRUE", bty="n", 
>inset=c(-0.5, -0.25)))
>So you'll need to give us a reproducible example if you want help.
>Duncan Murdoch
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list