0

I was wondering how I place a gap between any particular column? My line of code looks like this right now:

ggplot(data.summary, aes(x = TREATMENT, y= mean, fill = EXPERIMENT )) +
  geom_bar(position="dodge")+
  geom_errorbar(aes(ymin=mean-se, ymax=mean+se),position=position_dodge(0.9), width=0.2)+
  labs(title="Paint - Walking occurrences", x="Experiment", y="Walking occurrences mean ")

I've linked my graph below, with arrows pointing to where I want the gaps to be.

enter image description here

Here is the head of my data:

Date BeeI.D     Age Treatment    Experiment WalkingTime GroomingTime RestingTime OnBackTime Vtime Grooming
1 6/03/2014 M06401 4DayOld      QMP+   BeforePaint         154          143           0          2     0        1
2 6/03/2014 M06401 4DayOld      QMP+         Paint         222           19           0         57     0        1
3 6/03/2014 M06402 4DayOld      QMP+ BeforeNoPaint         278            1           2         15     0        1
4 6/03/2014 M06402 4DayOld      QMP+       NoPaint         153           38          96         10     0        5
5 6/03/2014 M06404 4DayOld      QMP+ BeforeNoPaint          86          211           0          2     0       10
6 6/03/2014 M06404 4DayOld      QMP+       NoPaint         182          112           0          4     0        5
  Shortgrooming Fanning Resting Walking Varroa Proboscis DislodgedVarroa OnBack OnBackAverage
1             0       0       0       4      0         0               0      3             1
2             0       0       0      31      4         0               0     30             2
3             7       0       1      20      0         0               0     18             1
4             4       0       0      10      0         0               0      2             5
5             0       0       0      13      0         0               0      3             1
6             0       0       0       7      0         0               0      3             1
  • Did you actually search? http://stackoverflow.com/questions/12040245/how-to-increase-the-space-between-the-bars-in-a-bar-plot-in-ggplot2 – ROLO Apr 10 '15 at 07:03
  • I tried to use the info on this post to create a space where I want to, but it doesn't seem to be working. – ellie-davionte Apr 10 '15 at 08:59
  • It's rather complicated to achieve what you are trying. Since two of your variable always belong togehter (beforeX and X), you could create a new variable `before` and write `aes(x = paste(TREATMENT,before),...`. This will give you four groups of bars instead of two. An alternative is using facets. – ziggystar Apr 10 '15 at 09:45
  • Thanks so much! So how exactly would that look? I'm guessing you would start with the code `before <-` ? @ziggystar – ellie-davionte Apr 10 '15 at 09:56
  • 5
    Welcome to SO! If you want a complete answer to your problem, you should make a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by posting a minimal sample of your data. – tonytonov Apr 10 '15 at 11:18
  • Is this enough of a sample of my data? I can add more if necessary. This whole thing is something I find confusing, I really appreciate your help!! – ellie-davionte Apr 11 '15 at 23:38

0 Answers0