问题描述
我想将图形的起点(在x轴和y轴上)都设置为零。我没有使用xlim()
和ylim()
函数。我在下面附加了我的代码。
setwd ("D:/Rcode/Assignment_2") #setting up the working directory
LightGrowth1 <- read.csv ("LightGrowth-1.csv") #reading the file and attaching it to a dataframe
Light <- LightGrowth1$light #attach our light values to a vector in R
Growth <- LightGrowth1$growth #attach our growth values to a vector in R
Labels <- c("Light","Growth") #create a vector using the labels
plot (Light,Growth,xlab = "Amount of Light (units)",ylab = "Plant Growth (units)",pch = 16,col= "firebrick",xlim = c(0,max (Light)),ylim = c (0,max (Growth)),main = "Plant Growth vs Amount of Light"
)
这是我的情节当前的样子:
解决方法
您的轴确实从0开始,xlim
和ylim
是您需要更改的轴。
我想您指的是轴与绘图之间的间距。
有两个额外的参数可以xaxs
和yaxs
进行更改。
plot (x,y,xlim=c(0,10),ylim=c(0,xaxs="i",yaxs="i")
这应该可以解决问题
有关更多信息,请参见par
帮助。