r - 你如何在 R 中改变你的情节的起点?
问题描述
我想将图表的起点(在 x 轴和 y 轴上)设置为零。我使用了xlim()
andylim()
功能无济于事。我在下面附上了我的代码。
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,10),
xaxs="i", yaxs="i")
这应该可以解决问题
有关更多信息,请参阅par
帮助。
推荐阅读
- field - 引用域函数中的另一个字段 (Odoo12)
- swift - 如何在 Swift 中将 Int 转换为 4 字节的字节数组?
- python - 如何在 python 中使用 asyncio 按下和释放?
- variables - 一个构建管道能否将值作为参数发送到它在 Azure DevOps 中触发的下一个管道
- python - 在循环中从嵌套字典中提取数据
- android - 需要帮助复制我们的 UI。将设置屏幕从 RecyclerView 移动到 PreferenceFragmentCompat (AndroidX)
- python - 如何在 cookie 中发送 oauth2 access_token ?(kong oauth2 插件)
- winforms - 如何以编程方式将值传递给 Devexpress 报告中的存储过程
- spring-security - 需要帮助使用 React-native、Spring Rest Api 和 ADFS 4.0 实施 OpenID 连接/OAuth2 流
- c++ - 在 Visual Studio 2019 中构建简单的点云可视化代码时,来自 PCL 的 3rd 方库的多个错误