需要用到ggh4x這個R包
library(ggplot2)
library(ggh4x)
dat<-data.frame(x=1:10,y=1:10)
ggplot(data=dat,aes(x=x,y=y))+
geom_point()+
theme_classic()
ggplot(data=dat,aes(x=x,y=y))+
geom_point()+
theme_classic()+
scale_x_continuous(breaks = c(1,3,5,7,9),
guide="axis_minor",
minor_breaks = c(2,4,6,8))
ggplot(data=dat,aes(x=x,y=y))+
geom_point()+
theme_classic()+
scale_x_continuous(breaks = c(1,3,5,7,9,10),
guide="axis_minor",
minor_breaks = c(2,4,6,8))+
guides(x=guide_axis_minor(trunc_lower = 1,
trunc_upper = 10),
y=guide_axis_truncated(trunc_lower = 2.5))
效果
歡迎大家關注我的公衆號
小明的數據分析筆記本
小明的數據分析筆記本 公衆號 主要分享:1、R語言和python做數據分析和數據可視化的簡單小例子;2、園藝植物相關轉錄組學、基因組學、羣體遺傳學文獻閱讀筆記;3、生物信息學入門學習資料及自己的學習筆記!