【问题标题】:R: ylim and xlab/ylab in plot() for grofit package not workingR:plot() 中的 ylim 和 xlab/ylab 用于 grofit 包不起作用
【发布时间】:2012-05-15 18:26:28
【问题描述】:

我正在尝试为 this 数据中的变量“ipen”与“year”绘制增长样条曲线。我使用的代码是:

grofit <- read.csv('http://dl.dropbox.com/u/1791181/grofit.csv')
# install.packages(c("grofit"), dependencies = TRUE)
require(grofit)
growth = gcFitSpline(grofit$year, grofit$ipen)
plot(growth)

这工作正常,并产生下面的情节。但问题是(a)我无法使用xlabylab 选项更改默认标签,并且(b)我无法使用ylim=c(0,100) 将x 轴的比例更改为(0,100)在plot() 声明中。我在grofit()documentation 中找不到任何指针。 .

【问题讨论】:

  • 我会采用 plot.gcFitSpline() 函数并对其进行自定义。

标签: r plot


【解决方案1】:

不要在gcFitSpline结果上直接使用plot,而是使用str(growth)探索曲线拟合对象的结构并确定要绘制的内容,或者查看plot.gcFitSpline代码(只需在控制台中输入不带括号的函数名称,然后按 Enter!)

例如:

growth = gcFitSpline(grofit$year, grofit$ipen)

plot (grofit$year, grofit$ipen, pch=20, cex=0.8, col="gray", ylim=c(0, 100),
     ylab="Growth", xlab="Year", las=1)
points(growth$fit.time, growth$fit.data, t="l", lwd=2)

这给出了:

【讨论】:

    【解决方案2】:

    实际上,我认为grofit 文档确实有关于此的指针:

    ...其他图形参数也可以作为参数传递[原文如此]。这目前没有任何效果,仅用于满足通用功能的要求。

    您可能必须针对您想要的图形参数重写 plot.gcFitSpline 函数,但可能有一个原因是该函数是这样的。

    顺便说一句,我不确定为您的数据提供与您正在使用的包相同的名称是否是个好主意。

    【讨论】:

      猜你喜欢
      • 2020-08-20
      • 2016-02-13
      • 1970-01-01
      • 2018-08-03
      • 2019-07-06
      • 2014-03-11
      • 2017-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多