如何减少 R 中轴刻度和轴标签之间的 space
How to reduce space between axis ticks and axis labels in R
我在 R 中生成了以下图:
代码:
ecdf.bdel<-ecdf(bDE[,6]) #### cumulative distribution of a vector of numeric values
curve(1-ecdf.bdel(x),col="red",xlim=r,xlab="r2",ylab="Fraction of SVs tagged") ###plotting inverse ecdf curve
剧情符合预期。但是,它在轴刻度和轴标签之间以及轴标签和轴实验室之间留下巨大的白色 space。
有人可以提供任何减少白色的技巧吗space。
像这样插入mgp
参数,看看能不能用。另请参阅 mar
参数以了解所有边的边距。您可以在 par()
函数中同时使用两者来解决您的问题。
par(mgp=c(3,1,0),mar(5,4,4,2)+0.1)
curve(1-ecdf.bdel(x),col="red",xlab="r2",ylab="Fraction of SVs tagged")
mgp
中的 first
值是您的 axis labels
靠近或远离轴的位置,较小的值表示靠近轴,较高的值表示远离轴轴即 x 和 y 轴。
mgp
中的 second
值是您的 tick labels
靠近或远离刻度的位置,较小的值表示更接近刻度,较高的值表示远离刻度轴即 x 和 y 轴。
mgp
中的 third
值是您的 ticks
靠近或远离轴线本身的位置,较小的值表示更接近轴线,较高的值表示远离轴上的轴线,即 x 和 y。
mar
是 c(bottom, left, top, right)
形式的数值向量,它给出了要在图的四个边上指定的边距行数。默认为 c(5, 4, 4, 2) + 0.1
.
从 curve()
函数中删除 xlim
。你的图表条件
par(mgp=c(10,4,0),mar=c(11,11,5,5)+0.1)
curve(1-ecdf.bdel(x),col="red",xlab="r2",ylab="Fraction of SVs tagged")
par(mgp=c(3,1,0),mar=c(5,4,4,2)+0.1)
curve(1-ecdf.bdel(x),col="red",xlab="r2",ylab="Fraction of SVs tagged")
示例:使用 plot
代替曲线。很相似
第一个案例:
par(mgp=c(7,3,0),mar=c(8,8,5,5)+0.1)
plot(1:10,xlab="X Axis", ylab="Y Axis", main="My Plot")
第二个案例
par(mgp=c(3,1,0),mar=c(5,4,4,2)+0.1)
plot(1:10,xlab="X Axis", ylab="Y Axis", main="My Plot")
这是你想要的吗?我没有其他选择来显示情节,如果这是你想要的,我会添加代码。
这是我做的:
data<-read.table("Ld.txt",F)
ecdf.bdel<-ecdf(data$V1) #### cumulative distribution of a vector of numeric values
curve(1-ecdf.bdel(x),col="red",xlab="r2",ylab="Fraction of SVs tagged") ###plotting inverse ecdf curve
我在 R 中生成了以下图:
代码:
ecdf.bdel<-ecdf(bDE[,6]) #### cumulative distribution of a vector of numeric values
curve(1-ecdf.bdel(x),col="red",xlim=r,xlab="r2",ylab="Fraction of SVs tagged") ###plotting inverse ecdf curve
剧情符合预期。但是,它在轴刻度和轴标签之间以及轴标签和轴实验室之间留下巨大的白色 space。
有人可以提供任何减少白色的技巧吗space。
像这样插入mgp
参数,看看能不能用。另请参阅 mar
参数以了解所有边的边距。您可以在 par()
函数中同时使用两者来解决您的问题。
par(mgp=c(3,1,0),mar(5,4,4,2)+0.1)
curve(1-ecdf.bdel(x),col="red",xlab="r2",ylab="Fraction of SVs tagged")
mgp
中的 first
值是您的 axis labels
靠近或远离轴的位置,较小的值表示靠近轴,较高的值表示远离轴轴即 x 和 y 轴。
mgp
中的 second
值是您的 tick labels
靠近或远离刻度的位置,较小的值表示更接近刻度,较高的值表示远离刻度轴即 x 和 y 轴。
mgp
中的 third
值是您的 ticks
靠近或远离轴线本身的位置,较小的值表示更接近轴线,较高的值表示远离轴上的轴线,即 x 和 y。
mar
是 c(bottom, left, top, right)
形式的数值向量,它给出了要在图的四个边上指定的边距行数。默认为 c(5, 4, 4, 2) + 0.1
.
从 curve()
函数中删除 xlim
。你的图表条件
par(mgp=c(10,4,0),mar=c(11,11,5,5)+0.1)
curve(1-ecdf.bdel(x),col="red",xlab="r2",ylab="Fraction of SVs tagged")
par(mgp=c(3,1,0),mar=c(5,4,4,2)+0.1)
curve(1-ecdf.bdel(x),col="red",xlab="r2",ylab="Fraction of SVs tagged")
示例:使用 plot
代替曲线。很相似
第一个案例:
par(mgp=c(7,3,0),mar=c(8,8,5,5)+0.1)
plot(1:10,xlab="X Axis", ylab="Y Axis", main="My Plot")
第二个案例
par(mgp=c(3,1,0),mar=c(5,4,4,2)+0.1)
plot(1:10,xlab="X Axis", ylab="Y Axis", main="My Plot")
这是我做的:
data<-read.table("Ld.txt",F)
ecdf.bdel<-ecdf(data$V1) #### cumulative distribution of a vector of numeric values
curve(1-ecdf.bdel(x),col="red",xlab="r2",ylab="Fraction of SVs tagged") ###plotting inverse ecdf curve