Ana Marija
2023-Jun-28 15:59 UTC
[R] horizontal grouped stacked plots and removing space between bars
I have code like this: data <- read.csv("test1.csv", stringsAsFactors=FALSE, header=TRUE) # Graph myplot=ggplot(data, aes(fill=condition, y=value, x=condition)) + geom_bar(position="dodge", stat="identity", width=0.5) + scale_fill_manual(values=c("#7b3294", "#c2a5cf", "#a6dba0", "#008837"))+ ylab("Performance (ns/day)") + facet_wrap(~specie,nrow=3, labeller = label_wrap_gen(width = 85), strip.position="bottom") + theme_bw() + theme(panel.grid = element_blank(), panel.spacing = unit(0, "mm"), legend.title=element_blank(), axis.title.x = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank(), axis.ticks.x=element_blank(), axis.title.y = element_text(angle = 90, hjust = 0.5)) myplot + theme(panel.grid.major = element_blank(), panel.grid.minor element_blank(), legend.title=element_blank(), panel.background = element_blank(), axis.title.x = element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank(), axis.title.y = element_text(angle = 90, hjust = 0.5)) And my data is this:> dput(data)structure(list(specie = c("gmx mdrun -gpu_id 1 -ntomp 16 -s benchMEM.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s benchMEM.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s benchMEM.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s benchMEM.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s MD_15NM_WATER.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s MD_15NM_WATER.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s MD_15NM_WATER.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s MD_15NM_WATER.tpr -nsteps 10000"), condition = c("Tesla P100-SYCL", "Tesla V100-SYCL", "Tesla P100-CUDA", "Tesla V100-CUDA", "Tesla P100-SYCL", "Tesla V100-SYCL", "Tesla P100-CUDA", "Tesla V100-CUDA"), value = c(75.8, 77.771, 63.297, 78.046, 34.666, 50.052, 32.07, 59.815)), class = "data.frame", row.names = c(NA, -8L)) How do I: 1. have these two plots next to each other, not on the top of each other 2. How do I remove spaces between those bars? [[alternative HTML version deleted]]
PIKAL Petr
2023-Jun-29 06:28 UTC
[R] horizontal grouped stacked plots and removing space between bars
Hi Anamaria Thanks for the data. See in line.> -----Original Message----- > From: R-help <r-help-bounces at r-project.org> On Behalf Of Ana Marija > Sent: Wednesday, June 28, 2023 6:00 PM > To: r-help <r-help at r-project.org> > Subject: [R] horizontal grouped stacked plots and removing space between > bars > > I have code like this: > > data <- read.csv("test1.csv", stringsAsFactors=FALSE, header=TRUE) > # Graph > myplot=ggplot(data, aes(fill=condition, y=value, x=condition)) + > geom_bar(position="dodge", stat="identity", width=0.5) + > scale_fill_manual(values=c("#7b3294", "#c2a5cf", "#a6dba0","#008837"))+ You have only 4 colours, you need 5 so I removed the line> ylab("Performance (ns/day)") + > facet_wrap(~specie,nrow=3, labeller = label_wrap_gen(width = 85), > strip.position="bottom") + > theme_bw() + > theme(panel.grid = element_blank(), > panel.spacing = unit(0, "mm"), > legend.title=element_blank(), > axis.title.x = element_blank(), > panel.grid.major = element_blank(), > panel.grid.minor = element_blank(), > panel.background = element_blank(), > axis.ticks.x=element_blank(), > axis.title.y = element_text(angle = 90, hjust = 0.5)) > > > > myplot + theme(panel.grid.major = element_blank(), panel.grid.minor > element_blank(), legend.title=element_blank(), > panel.background = element_blank(), axis.title.x = element_blank(), > axis.text.x=element_blank(), axis.ticks.x=element_blank(), > axis.title.y = element_text(angle = 90, hjust = 0.5))And here I got 2 plots one above the other so I presume this is what you wanted. Spacing between bars https://www.statology.org/ggplot2-space-between-bars/ Cheers Petr> > And my data is this: > > > dput(data) > structure(list(specie = c("gmx mdrun -gpu_id 1 -ntomp 16 -s > benchMEM.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s > benchMEM.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s > benchMEM.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s > benchMEM.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s > MD_15NM_WATER.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s > MD_15NM_WATER.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s > MD_15NM_WATER.tpr -nsteps 10000", "gmx mdrun -gpu_id 1 -ntomp 16 -s > MD_15NM_WATER.tpr -nsteps 10000"), condition = c("Tesla P100-SYCL", > "Tesla V100-SYCL", "Tesla P100-CUDA", "Tesla V100-CUDA", "Tesla > P100-SYCL", "Tesla V100-SYCL", "Tesla P100-CUDA", "Tesla V100-CUDA"), > value = c(75.8, 77.771, 63.297, 78.046, 34.666, 50.052, 32.07, > 59.815)), class = "data.frame", row.names = c(NA, -8L)) > > How do I: > > 1. have these two plots next to each other, not on the top of eachother> 2. How do I remove spaces between those bars? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code.