I'm using gggenes to generate a plot
library(ggplot2)
library(gggenes)
df <- filter(example_genes, molecule %in% c("Genome1", "Genome2"))
just to generate a single gene line
df$molecule <- "Genome1"
head(df)
molecule gene start end strand orientation
1 Genome1 genA 15389 17299 reverse 1
2 Genome1 genB 17301 18161 forward 0
3 Genome1 genC 18176 18640 reverse 1
4 Genome1 genD 18641 18985 forward 0
5 Genome1 genE 18999 20078 reverse 1
6 Genome1 genF 20086 20451 forward 1
now to plot
p1 <- ggplot(df, aes(xmin = start, xmax = end, y = molecule)) +
geom_gene_arrow() +
theme_genes() +
geom_text(data=df %>% mutate(start = (start + end)/2),
aes(x=start, label = gene), nudge_y = -0.044, angle=70 ) +
theme(axis.line=element_blank(),
axis.text.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks=element_blank(),
axis.title.x=element_blank(),
axis.title.y=element_blank(),
legend.position="none",
panel.background = element_blank(),
panel.border=element_blank(),
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
plot.background=element_blank())
but I just want to reduce the size in y axis or eliminate the zone marked with a red X
my real problem is that I tried to merge 2 plots
head(df2, 3)
sample size type
1 S300 135785 E
2 S306 135785 E
3 S314 135785 C
>
> head(df3, 3)
sample position nucl group
1 S300 1 G 0
2 S306 1 G 0
3 S314 1 - 0
plot
p2 <- ggplot(mapping = aes(y = sample)) +
geom_col(aes(x = size, fill = type), data = df2) +
scale_fill_manual(values = c("grey68", "grey87")) +
geom_errorbar(aes(xmin = position, xmax = position), data = df3, size = 0.01, linetype = 1, alpha = 0.1, color = "black") +
#expand_limits(y= c(-((80*nrow(df_bar))/100), 1)) +
#coord_polar(theta = "x") +
theme_bw() +
theme(legend.position="none", #none
panel.background = element_rect(fill = 'white', color = 'white'), # background color "white"
plot.margin = margin(grid::unit(0, "cm")),
panel.border = element_blank(),
panel.grid = element_blank(),
panel.spacing = element_blank(),
axis.title.y= element_blank(),
axis.text.y = element_blank(),
axis.ticks.y = element_blank(), # borrar las marcas en y
axis.title.x = element_blank(),
axis.text.x = element_blank()) +
guides(fill=guide_legend(nrow=1))
now merge both plots
library("cowplot")
plot_grid( p2, p1, align = "hv", ncol = 1)
I just want to reduce the empty (in X red) zone among both plots
How can I make it ?
Thanks so much