Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to put space between groups of stacked bars in ggplot2
    primarykey
    data
    text
    <p>I'm trying to group the stacks spatially in pairs such that the 0W treatment is close to the corresponding 6W treatment with bigger spaces between pairs of different treatments. I've included a column "group" to show which pairs should go together. </p> <p>Data: </p> <pre><code> trt org time copy group 1 Notill_D0 0W fungi 0W 9.78e+07 a 2 Notill_D707 0W fungi 0W 1.55e+07 b 3 Native_D0 0W fungi 0W 4.02e+07 c 4 Native_D707 0W fungi 0W 1.04e+07 d 5 Notill_D0 6W fungi 6W 5.51e+07 a 6 Notill_D707 6W fungi 6W 1.43e+07 d 7 Native_D0 6W fungi 6W 1.60e+07 c 8 Native_D707 6W fungi 6W 8.64e+06 b 9 Notill_D0 0W bacteria 0W 2.98e+08 a 10 Notill_D707 0W bacteria 0W 7.79e+07 b 11 Native_D0 0W bacteria 0W 2.33e+08 c 12 Native_D707 0W bacteria 0W 2.20e+08 d 13 Notill_D0 6W bacteria 6W 3.37e+08 a 14 Notill_D707 6W bacteria 6W 8.84e+07 d 15 Native_D0 6W bacteria 6W 3.24e+08 c 16 Native_D707 6W bacteria 6W 1.89e+08 b </code></pre> <p>dput:</p> <pre><code>structure(list(trt = structure(c(5L, 7L, 1L, 3L, 6L, 8L, 2L, 4L, 5L, 7L, 1L, 3L, 6L, 8L, 2L, 4L), .Label = c("Native_D0 0W", "Native_D0 6W", "Native_D707 0W", "Native_D707 6W", "Notill_D0 0W", "Notill_D0 6W", "Notill_D707 0W", "Notill_D707 6W"), class = "factor"), org = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("bacteria", "fungi"), class = "factor"), time = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("0W", "6W"), class = "factor"), copy = c(97800000, 15500000, 40200000, 10400000, 55100000, 14300000, 1.6e+07, 8640000, 2.98e+08, 77900000, 2.33e+08, 2.2e+08, 3.37e+08, 88400000, 3.24e+08, 1.89e+08), group = structure(c(1L, 2L, 3L, 4L, 1L, 4L, 3L, 2L, 1L, 2L, 3L, 4L, 1L, 4L, 3L, 2L ), .Label = c("a", "b", "c", "d"), class = "factor")), .Names = c("trt", "org", "time", "copy", "group"), class = "data.frame", row.names = c(NA, -16L)) </code></pre> <p>code:</p> <pre><code> colvec &lt;-c("blue", "orange") ggplot(Suz2, aes(factor(trt), copy)) + geom_bar(aes(fill = factor(org)), stat="identity", width = 0.7) + scale_fill_manual(values = colvec)+ theme(panel.background = element_rect(fill='white', colour='white'), panel.grid = element_line(color = NA), panel.grid.minor = element_line(color = NA), panel.border = element_rect(fill = NA, color = "black"), axis.text.x = element_text(size=10, colour="black", face = "bold"), axis.title.x = element_text(vjust=0.1, face = "bold"), axis.text.y = element_text(size=12, colour="black"), axis.title.y = element_text(vjust=0.2, size = 12, face = "bold")) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload