你如何在 R 中改变你的情节的起点? [英] How do you change the starting point of your plot in R?

查看:56
本文介绍了你如何在 R 中改变你的情节的起点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将图形的起点(在 x 轴和 y 轴上)设置为零.我使用了 xlim()ylim() 函数无济于事.我在下面附上了我的代码.

I want to set the starting point of my graph (both in the x- and y-axis) to be zero. I have used the xlim() and ylim() functions to no avail. I have attached my code below.

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"
       
        )

这是我的情节目前的样子:

This is what my plot currently looks like:

推荐答案

你的坐标轴确实从 0 开始,而 xlimylim 是你需要改变的.

Your axes do start at 0, and xlim and ylim are what you need to change that.

我认为您指的是轴和图之间的间距.有两个额外的参数可以让你改变它,xaxsyaxs.

What I think you are referring to is the spacing between the axes and the plot. There are two extra parameters that allow you to change that, xaxs and yaxs.

plot (x, y, xlim=c(0,10), ylim=c(0,10),
      xaxs="i", yaxs="i") 

这应该可以解决问题

有关详细信息,请参阅 par 帮助.

See the par help for more info.

这篇关于你如何在 R 中改变你的情节的起点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆