Gg.gap
Easy to define segments in y-axis for 'ggplot2'.
Install / Use
/learn @ChrisLou-bioinfo/Gg.gapREADME
gg.gap
Easy to define segments in y-axis for 'ggplot2'.
安装
You can install gg.gap from CRAN:
install.packages("gg.gap")
Or get the development version from Github:
# install.packages("devtools")
devtools::install_github("ChrisLou-bioinfo/gg.gap")
使用
data(mtcars)
library(ggplot2)
p<-ggplot(data = mtcars, aes(x = gear, fill = gear)) +
geom_bar() +
ggtitle("Number of Cars by Gear") +
xlab("Gears")
#single segments and missing tick_width
gg.gap(plot=p,
segments=c(5,10),
ylim=c(0,50))
#tick_width can be one or more numbers
gg.gap(plot=p,
segments=c(5,10),
tick_width = c(1,10),
ylim=c(0,50))
#segments list cantains more than one number vectors
gg.gap(plot=p,
segments=list(c(2.5,4),c(5,10)),
tick_width = c(1,0.5,10),
ylim=c(0,50))
#rel_heights can set the relative height for segments and segmented y-axis
gg.gap(plot=p,
segments=list(c(2.5,4),c(5,10)),
tick_width = c(1,0.5,10),
rel_heights=c(0.2,0,0.2,0,1),
ylim=c(0,50))
#reversed y-axis
p<-ggplot(data = mtcars, aes(x = gear, fill = gear)) +
geom_bar() +
ggtitle("Number of Cars by Gear") +
xlab("Gears")+
scale_y_continuous(trans = 'reverse')
#single segments and missing tick_width
gg.gap(plot=p,
segments=c(10,5),
ylim=c(15,0))
#for facet()
library(ggplot2)
p<-ggplot(mtcars,aes(mpg,hp))+geom_point()
p1<-p+facet_wrap(~cyl,scales="free")
gg.gap(plot = p1,ylim = c(60,200),segments = c(100,120))
Related Skills
node-connect
340.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
340.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.2kCommit, push, and open a PR
