Re: Geom_bar problem

25 views
Skip to first unread message
Message has been deleted

Roman Luštrik

unread,
Jul 12, 2017, 5:04:17 AM7/12/17
to bic ton, ggplot2
Using small amount of formatting and with little use of spaces you could substantially increase readability of your code.

As for the crux of the matter, precalculate this true/false variable and make sure that it's a factor with two variables (sensu `factor(1, levels = 1:2)`).

Cheers,
Roman


On Wed, Jul 12, 2017 at 10:53 AM, bic ton <bict...@gmail.com> wrote:

Hi,

case 1

choosev <- c(0.005,0.005,0.4,0.4,0.0205,0.0205,0.05,0.05)

 Var1 <- rep(c("A1","A2"),4)

Var2 <- c("Q1","Q1","Q2","Q2","Q3","Q3","Q4","Q4")

  Freq <- c(4,2,6,2,6,4,9,3)

 err<- c(0.04,0.02,0.06,0.02,0.06,0.04,0.09,0.03)


DF <- data.frame(Var1,Var2,Freq,choosev,err)


ggplot(DF,aes(x=factor(Var2),y=Freq))+ geom_bar(stat="identity",aes(fill=Var1,colour=choosev<0.05),position="dodge")+scale_colour_manual(values=c(NA,"black"))+geom_errorbar(aes(ymax = Freq+ err, ymin = Freq- err, group=Var1) , position = position_dodge(width = 0.9), width = 0.5)

Hear works with no problem. this distinguish bars with choosev < 0.05 (with borders)  and choosev > 0.05 (no borders) 


case 2

Now imagine I have this values where all of them are <0.05. 

choosev <- c(0.005,0.005,0.04,0.04,0.0205,0.0205,0.005,0.005)

So I expect bars with borders (to be consistent with my first graph) but now all bars are without borders (although it changes to TRUE).

I need the plots in case 1 and case 2 to be consistent. any ideas?

Thanks

Bic


--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
In God we trust, all others bring data.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages