I'm looking at behavior of different groups of people (called Clusters
in this data set) and their preference for the type of browser they use. I want to create a bar graph that shows the percentage of each cluster that is using each type of browser.
Here is some code to generate a similar dataset (please ignore that the percentages for each cluster will not add up to 1):
browserNames <- c("microsoft","mozilla","google")
clusterNames <- c("Cluster 1","Cluster 2","Cluster 3")
percentages <- runif(n=length(browserNames)*length(clusterNames),min=0,max=1)
myData<-as.data.frame(list(browserNames=rep(browserNames,3),
clusterNames=rep(clusterNames,each=3),
percentages=percentages))
Here's the code I've been able to come up with so far to get the graph I desire:
ggplot(myData, aes(x=browserNames, y=percentages, fill=factor(clusterNames))) +
geom_bar(stat="identity",position="dodge") +
scale_y_continuous(name="Percent Weight", labels=percent)
I want the fill for each cluster to be a gradient fill with high and low values that I determine. So, in this example, I would like to be able to set 3 high and low values for each cluster that is represented.
I've had trouble with the different scale_fill commands, and I'm new enough to ggplot that I am pretty sure I'm probably just doing it wrong. Any ideas?
Edit: Here is a picture of what I'm looking for:
(Original image available at https://www.dropbox.com/s/py6hifejqz7k54v/gradientExample.bmp)