tags:

views:

31

answers:

3

Greetings, I am trying to create a bar chart of the data posted below (referred to in my code as topTwoTable), disaggregated by group type. I've scanned through multiple online forums, as well as Hadley's website, and stuck when it comes to manually altering the fill color of the bars on the basis of treatment type.

                      Response Count Proportion     ConfLow  ConfHigh GroupType    Treatment
Very likely or Somewhat likely    43  0.2116694  0.15458802 0.2687508     Total     Pre-poll
Very likely or Somewhat likely    18  0.2370675  0.14065843 0.3334766      Male     Pre-poll
Very likely or Somewhat likely    24  0.1926894  0.12200356 0.2633752    Female     Pre-poll
Very likely or Somewhat likely    28  0.2173320  0.14493375 0.2897302     13-34     Pre-poll
Very likely or Somewhat likely     9  0.2199610  0.09055556 0.3493664     35-44     Pre-poll
Very likely or Somewhat likely     6  0.1801985  0.04844103 0.3119560       45+     Pre-poll
Very likely or Somewhat likely    48  0.1933666  0.14328532 0.2434478     Total Experimental
Very likely or Somewhat likely    26  0.2187302  0.14279015 0.2946703      Male Experimental
Very likely or Somewhat likely    21  0.1645328  0.09909490 0.2299707    Female Experimental
Very likely or Somewhat likely    41  0.1782259  0.12775486 0.2286970     13-34 Experimental
Very likely or Somewhat likely     6  0.4162840  0.16706771 0.6655004     35-44 Experimental
Very likely or Somewhat likely     1  0.1676391 -0.13936540 0.4746436       45+ Experimental

The code

hist_cut <- ggplot(topTwoTable, aes(x=GroupType, y=Proportion, fill=Treatment, stat="identity")) #STUDY UP ON ggplot()
limits <- aes(ymax = ConfHigh, ymin=ConfLow)

(hist_cut + geom_bar(position="dodge") + scale_y_continuous(name="Share",formatter = "percent") 
 + scale_x_discrete(breaks = NA)
 + geom_text(aes(label = GroupType,y=-0.01)))

generates a nice enough looking chart, but instead of the default rust and teal colors I'd like to have pale blue for the pre-poll group and dark blue for the experimental group.

Any thoughts?

Cheers, Aaron

A: 

sdfsadfasdfasdf

sdfs
Left hand algorithm?
Marek
+1  A: 

You'll want to specify your colors with "scale_colour_manual"

http://had.co.nz/ggplot2/scale_manual.html

I believe adding the following to the end of your current code should work.

+ scale_colour_manual(values = c("light blue"," dark blue"))
Brian
A: 

Dear all,

Thank you for yout responses, +scale_colour_manual was indeed the tricky. Sorry for the amateur posting and thanks for the help!

Aaron

Aaron
You should edit your question than post an answer. Your answer is not an aswer ;)
Marek