如何在R中更改绘图的起点?

如何在R中更改绘图的起点?,r,scatter-plot,R,Scatter Plot,我想将图形的起点(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 <- Li

我想将图形的起点(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"
       
        )
setwd(“D:/Rcode/Assignment_2”)#设置工作目录

LightGrowth1您的轴确实从0开始,而
xlim
ylim
是您需要更改的

我想你指的是轴和绘图之间的间距。 有两个额外的参数允许您进行更改,
xaxs
yaxs

plot (x, y, xlim=c(0,10), ylim=c(0,10),
      xaxs="i", yaxs="i") 
这应该能奏效


有关更多信息,请参阅
par
帮助。

他们已经从0开始。我不知道你想改变什么。如果您希望x轴从2开始,我可以理解,但使用
xlim
命令很容易做到这一点,这就是我希望图形的外观(散点图版本)。基于此,图表从零基线开始。是我想要的图形的样子(散点图版本)。基于此,图表从零基线开始。