0

I have the following boxplot, where grouping generates double lanes to be compared with a single control group.

require(reshape2)
require(ggplot2)
require(dplyr)
require(tidyr)

A1_0d_ret<-rnorm(1:100,20)
A2_4d_ret<-rnorm(1:100,18)
A3_14d_ret<-rnorm(1:100,30)
A4_4d_pan<-rnorm(1:100,7)
A5_14d_pan<-rnorm(1:100,40)

data<-data.frame(A1_0d_ret,
A2_4d_ret,
A3_14d_ret,
A4_4d_pan,
A5_14d_pan)

long.data<-melt(data)

long.data_<-separate(data = long.data, col = variable, into = c("group", "treatment", "species"), sep = "_", remove=FALSE)

ggplot(long.data_, aes(x=treatment, y=log(value), group=variable))+
geom_boxplot(aes(col=species), outlier.shape = NA, width=0.2 )+
scale_fill_manual(values=c("white", "black"))+
geom_point(shape=16,size=0.8, col= "grey", position=position_dodge(0.2))+
geom_vline(xintercept = 1.5, linetype="dotted")+
scale_x_discrete("NONO")+
scale_y_continuous("X (ng)")+
theme_classic()

This is the output: see control group on the lafthand side Please, I have the following naive question:

How do I make the control group, i.e. in the first lane, of the same width as other groups?

EDIT: I am using RStudio Version 1.1.456 – © 2009-2018 RStudio, Inc.

Scientist
  • 1,061
  • 2
  • 13
  • 30
  • looks like it is the same width as the other groups... – Chris Aug 20 '18 at 17:29
  • @Chris Not from my side?.. I meant the box width. Perhaps "lane" was not a good term, I am editing the question and adding an image. – Scientist Aug 20 '18 at 17:31
  • 1
    right...the box widths are the same when i run your code – Chris Aug 20 '18 at 17:33
  • 1
    interesting...i'm using ggplot2_2.2.1.9000, so maybe you're using a different version and that's why the box widths are different. – Chris Aug 20 '18 at 17:45
  • @Chris Apparently then I have already two issues from my RStudio version already. See also my other thread on italics on the labels of the same plot!.. https://stackoverflow.com/questions/51935883/italics-not-working-on-labels-in-ggplot2 This is very unfortunate. Thanks for testing. – Scientist Aug 20 '18 at 18:01
  • 1
    i get the same problem, but it works for me with an answer of the dublicated link. Try adding `position = position_dodge2(preserve="single")` to your boxplot arguments – mischva11 Aug 20 '18 at 18:27
  • @mischva11 Great! Thanks! I was unable to find this duplicate entry before. Perhaps make it an answer so I can reward you here. – Scientist Aug 20 '18 at 18:37
  • 1
    this is not possible since it is marked as duplicate, so you can't add answers anymore – mischva11 Aug 20 '18 at 18:38

0 Answers0