I have the following plot where I wish to remove the black lines between columns but not the outline for a whole block e.g. wild and landrace. Is there a way to do so based on the code I'm using? Thanks in advance!
Example code:
library(tidyr)
library(dplyr)
library(tibble)
library(ggplot2)
library(forcats)
library(RColorBrewer)
tbl = read_table("path/to/test.3.Q", col_names=c('comp1','comp2','comp3'))
tbl
df2 <- pivot_longer(tbl, comp1:comp3)
df2
sampleID = c(rep("INLUP00165", 3), rep("INLUP00169", 3), rep("INLUP00208", 3), rep("INLUP00214", 3), rep("INLUP00228", 3), rep("INLUP00245", 3),
rep("INLUP00325", 3), rep("INLUP00332", 3), rep("INLUP00393", 3), rep("INLUP00418", 3), rep("INLUP00496", 3))
variety = c(rep("wild", 3), rep("landrace", 3), rep("wild", 6), rep("landrace", 3), rep("wild", 3), rep("landrace", 18))
tbl2 <- cbind(sampleID, variety, df2)
tbl2
colnames(tbl2)[3] <- "comp"
tbl2
k3plot <-
ggplot(tbl2, aes(factor(sampleID), value, fill=comp)) +
geom_col(color="black", size=0.1, width=1) +
facet_grid(~fct_inorder(variety), switch="x", scales="free", space="free") +
theme_minimal() + labs(x="Individuals", title="K=3", y="components") +
scale_y_continuous(expand=c(0, 0)) +
scale_x_discrete(expand=expand_scale(add=1)) +
theme(
panel.spacing.x=unit(0.1, "lines"),
axis.text.x=element_blank(),
panel.grid=element_blank()
) +
scale_fill_brewer(palette="Paired", guide='none')
k3plot
and a dput(tbl)
structure(list(comp1 = c(0.000304534914903343, 7.25639850429616e-08,
2.27430740759918e-42, 0, 1, 7.37646416837379e-07, 1, 6.76272702548886e-06,
0, 3.04290442727506e-05, 4.25612745047488e-09, 1.18218178221686e-16
), comp2 = c(0.999695539474487, 0.99999988079071, 1, 1, 3.6168054052767e-30,
0.999999284744263, 2.82813122498233e-29, 1.06498683288686e-43,
1, 4.66462843997956e-16, 1, 1), comp3 = c(5.66402567378596e-16,
7.41350128733039e-16, 1.40129846432482e-45, 1.26116861789234e-44,
6.73797980640088e-16, 1.86443519971077e-23, 4.54367988546311e-14,
0.999993205070496, 0, 0.999969601631165, 5.97792615408821e-09,
3.16024730889457e-37)), class = c("spec_tbl_df", "tbl_df", "tbl",
"data.frame"), row.names = c(NA, -12L), spec = structure(list(
cols = list(comp1 = structure(list(), class = c("collector_double",
"collector")), comp2 = structure(list(), class = c("collector_double",
"collector")), comp3 = structure(list(), class = c("collector_double",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), skip = 0), class = "col_spec"))