I have used the following code to generate the histogram. However, I want to make the y axis longer since it is too short, may I know how to do it?
我使用以下代码生成直方图。但是,我想让y轴更长,因为它太短了,我可以知道怎么做吗?
> h<-hist(data, breaks=c(0,1, 2, 3, 4), col="grey",xlim = c(0,4), xlab="",xaxt="n",main="")
> axis(side=1, at=0.5:3.5, labels=c(1,2,3,4))
1 个解决方案
#1
2
You could use ylim
parameter to hist
:
您可以使用ylim参数进行hist:
hist(mtcars$mpg, ylim=c(0,15))
c(0,15)
gives the range to y axis.
c(0,15)给出了y轴的范围。
A graph will fill whole available area (i.e. window). You could limit that by using layout
.
图表将填充整个可用区域(即窗口)。您可以通过使用布局来限制它。
layout(matrix(c(1, 0, 0, 1, 0, 0, 1, 2, 3), 3, 3, byrow = TRUE))
hist(mtcars$mpg, ylim=c(0,15))
#1
2
You could use ylim
parameter to hist
:
您可以使用ylim参数进行hist:
hist(mtcars$mpg, ylim=c(0,15))
c(0,15)
gives the range to y axis.
c(0,15)给出了y轴的范围。
A graph will fill whole available area (i.e. window). You could limit that by using layout
.
图表将填充整个可用区域(即窗口)。您可以通过使用布局来限制它。
layout(matrix(c(1, 0, 0, 1, 0, 0, 1, 2, 3), 3, 3, byrow = TRUE))
hist(mtcars$mpg, ylim=c(0,15))