Hhi Ujjwal
As Jim says a lot of people don't like the barplot with error bars approach
see http://biostat.mc.vanderbilt.edu/wiki/Main/DynamitePlots and links for some
of the reasons why.
Besides, in Tufte's terms most of a barplot is 'chart junk'.
John Kane
Kingston ON Canada
> -----Original Message-----
> From: drjimlemon at gmail.com
> Sent: Mon, 26 Oct 2015 11:32:35 +1100
> To:
> Subject: Re: [R] How to plott bar graphics
>
> Hi Ujjwal,
> Given that you have asked about a barplot and included standard errors,
> you
> probably want something like the following:
>
> uk.df<-read.table(text>
"habitat,proportion_use,proportion_use_SE,selectivity_index,selectivity_index_SE
> grassland,0.56,0.22,0.72,0.29
> sal_forest,0.11,0.04,-0.43,0.13
> bamboo-mix,0.22,0.07,0.05,0.02
> miscellaneous,0.11,0.03,-0.59,0.18",sep=",",header=TRUE)
> library(plotrix)
>
barpos<-barp(uk.df[c("proportion_use","selectivity_index")],
> names.arg=c("proportion_use","selectivity_index"),
> main="Habitat Use Plot",ylab="Proportion of use",
> col=2:5,ylim=c(-1,1.1))
> dispersion(barpos$x,barpos$y,
>
ulim=as.matrix(uk.df[c("proportion_use_SE","selectivity_index_SE")]))
> legend(0.7,-0.3,uk.df$habitat,fill=2:4)
>
> You will almost certainly be told that you shouldn't do this, so maybe
> you
> should consider:
>
> matplot(matrix(c(0.9,1.1,1.9,2.1,2.9,3.1,3.9,4.1),nrow=4,byrow=TRUE),
> uk.df[c("proportion_use","selectivity_index")],
> ylab="Proportion and selectivity of use",
>
ylim=c(-1,1.1),pch=18:19,col=2:3,xaxt="n",xlab="Habitat",
> main="Habitat Use Plot")
> axis(1,at=1:4,labels=uk.df$habitat)
> dispersion(matrix(c(0.9,1.1,1.9,2.1,2.9,3.1,3.9,4.1),nrow=4,byrow=TRUE),
>
as.matrix(uk.df[c("proportion_use","selectivity_index")]),
>
ulim=as.matrix(uk.df[c("proportion_use_SE","selectivity_index_SE")]))
> legend(2.5,1,c("Proportion of use","Selectivity of
use"),
> pch=18:19,col=2:3)
>
> Jim
>
>
> On Sun, Oct 25, 2015 at 11:22 PM, Michael Dewey <lists at
dewey.myzen.co.uk>
> wrote:
>
>> Dear Ujjwal
>>
>> Two problems
>> 1 - you posted in HTML so your post is unreadable
>> 2 - your attached graphic was not in one of the formats which R-help
>> accepts and so was stripped
>>
>>
>> On 25/10/2015 11:04, Ujjwal Kumar wrote:
>>
>>> HI friends
>>> I am struggling in plotting bar graph with this data sets in R.
>>> although I
>>> can plot it in Microsoft excel( attached graphics). I need help in
>>> coding
>>> it for R.(SE=standar error)
>>>
>>>> data
>>>>>
>>>> habitat
>>>> proportion_use
>>>> proportion_use_SE
>>>> selectivity_index
>>>> selectivity_index_SE
>>>> grassland
>>>> 0.56
>>>> 0.22
>>>> 0.72
>>>> 0.29
>>>> sal_forest
>>>> 0.11
>>>> 0.04
>>>> -0.43
>>>> 0.13
>>>> bamboo-mix
>>>> 0.22
>>>> 0.07
>>>> 0.05
>>>> 0.02
>>>> miscellaneous
>>>> 0.11
>>>> 0.03
>>>> -0.59
>>>> 0.18
>>>>
>>>>> excel-graphics
>>>>>
>>>>
>>>>
>>>> regards:
>>>> Ujjwal
>>>>
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more,
see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>> --
>> Michael
>> http://www.dewey.myzen.co.uk/home.html
>>
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.