ChrisLou-bioinfo / gg.gap

Easy to define segments in y-axis for 'ggplot2'.
GNU General Public License v3.0
27 stars 5 forks source link

Faill to add gap to the reverse t axis #4

Open YuZhang-learner opened 3 years ago

YuZhang-learner commented 3 years ago

Dear all, I dont know why there is a error in add gap to the reverse t axis

`mypal <- pal_npg("nrc", alpha = 1)(9) x1 <- x$data %>% mutate( Genus = factor( Genus,levels = c("Fusarium","Pseudeurotium","Mortierella","Penicillium", "Arthrobotrys","Trichoderma","Talaromyces","Westerdykella", "Aspergillus","Zopfiella","Saitozyma", "Curvularia","Psilocybe","Plectosphaerella","Emericellopsis", "Metarhizium","Clonostachys","Paraglomus","Byssonectria") )) %>% ggplot(aes(x=Genus,y=Abundance,fill= Genus)) + geom_col(position = position_dodge(width = 0.9), width = 0.7) + geom_hline(yintercept = 0) + scale_fill_manual(values=c("Pseudeurotium"="#E64B35FF", "Penicillium"="#4DBBD5FF", "Talaromyces"="#00A087FF", "Zopfiella"="#3C5488FF", "Saitozyma"="#F39B7FFF", "Curvularia"="#8491B4FF", "Psilocybe"="#91D1C2FF", "Emericellopsis"="#DC0000FF", "Clonostachys"="#7E6148FF"))+ scale_x_discrete(labels=NULL,position = "top",breaks=NULL)+ scale_y_continuous( expand = c(0,0), trans = "reverse" ) + xlab (NULL) +

ylab ("Soil Relative Abundance (%)") +

ylab(NULL)+ theme( panel.grid = element_blank(), panel.background = element_rect(fill = 'transparent'), axis.line.y = element_line(colour = 'black'), plot.title = element_text(hjust = 0.5, face = 'plain'), axis.line.x.top = element_blank(),legend.position = 'none' )

x1 gg.gap(plot = x1,segments = c(30,2),ylim=c(100,0))`

1610264252(1)

I do a revrse y axis, it should be "segments = c(30,2),ylim=c(100,0))' So,why is it?

I also found that, it cant add a gap on a plot after the X-axis and the Y-axis are switched.