R 减小y标签和绘图区域ggplot之间的距离
我的代码如下:R 减小y标签和绘图区域ggplot之间的距离,r,ggplot2,R,Ggplot2,我的代码如下: df=data.frame(time=as.factor(rep(0.5:9.5,each=10)), roi=rep(1:10,10), area=runif(100, 5.0, 7.5)) df$time=factor(df$time, levels=rev(levels(df$time))) ggplot(data=df, aes(x=factor(roi), y=time, fill = area)) + theme_minima
df=data.frame(time=as.factor(rep(0.5:9.5,each=10)),
roi=rep(1:10,10),
area=runif(100, 5.0, 7.5))
df$time=factor(df$time, levels=rev(levels(df$time)))
ggplot(data=df, aes(x=factor(roi), y=time, fill = area)) +
theme_minimal() +coord_fixed(ratio=1) +
geom_tile(colour = NA, width = 1.5, height = 1)+
scale_fill_gradient(low="black",high="white") +
scale_y_discrete(name="Time (min)",
expand =c(0,0),breaks=c(0.5,2.5,5.5,7.5,9.5),
labels=c(0,15,30,45,60))
如何使y标签靠近绘图区域
非常感谢您的回复 将
主题中的轴.ticks.length
设置为零,以删除此空格
ggplot(data=df, aes(x=factor(roi), y=time, fill = area)) +
theme_minimal() +
coord_fixed(ratio=1) +
geom_tile(colour = NA, width = 1.5, height = 1)+
scale_fill_gradient(low="black",high="white") +
scale_y_discrete(name="Time (min)",
expand =c(0,0),breaks=c(0.5,2.5,5.5,7.5,9.5),
labels=c(0,15,30,45,60)) +
theme(axis.ticks.length = unit(0, "lines"))
将主题中的轴.ticks.length
设置为零以删除此空格
ggplot(data=df, aes(x=factor(roi), y=time, fill = area)) +
theme_minimal() +
coord_fixed(ratio=1) +
geom_tile(colour = NA, width = 1.5, height = 1)+
scale_fill_gradient(low="black",high="white") +
scale_y_discrete(name="Time (min)",
expand =c(0,0),breaks=c(0.5,2.5,5.5,7.5,9.5),
labels=c(0,15,30,45,60)) +
theme(axis.ticks.length = unit(0, "lines"))
非常感谢你的帮助!非常感谢你的帮助!