I am attempting to make a grouped bar chart...with a few modifications.
I have four "columns" for my chart: Quarter, Person, Percentage, Total Percentage. An example of my data looks like this:
| Person | Quarter | Percentage | Total Percentage |
|-------- |--------- |------------ |------------------ |
| A | 1 | 40% | 50% |
| A | 2 | 45% | 50% |
| A | 3 | 55% | 50% |
| A | 4 | 60% | 50% |
| B | 1 | 35% | 42% |
and so forth for.
I have successfully made my bar chart using this code:
ggplot(data=point3, aes(x=Person, y=Percentage, fill=Quarter)) +
+ geom_bar(colour="black", stat="identity", position=position_dodge(), size=.3)
+ scale_fill_hue(name="Quarter")
+ xlab(" ") + ylab("Percentage")
+ theme_bw()
However, I would like to change a few things. First, I would like to space out the x-axis. There are four bars per person and I was wondering how I could make it so that there is more space in between each person. I've run into trouble with this because the X axis doesn't contain any numbers of any sort. Does anyone know how to do this?
Second, I would like to add a vertical line for each person representing their total percentage. This way, it would be easy for the viewer to see which quarter the person performed under their yearly average and which quarter they over-performed. I have had a little success with this using
geom_point(data=point3, aes(x=Person, y=Total Percentage))
at the end of the previous code, but this simply adds a dot between the second and third bars (the middle). I made a mock up of this using a grouped bar chart I found via Google. This one only has 3 bars, but perhaps you can get the idea. Some of the problems I ran into this time were, although they are on the same scale, the y-axis for the bar charts is "Performance" while the y-axis for the line is "Total Performance". R did not seem to like this. Also, the whole x-axis not being numeric.
I used ggplot2 because I didn't know what else to use, but if you know of any technique/package to make this work, I am happy to change that. I am also aware I may need to reshape my data, that is cool, too.
Thanks so much.