简体   繁体   English

R:plot()中的ylim和xlab / ylab对于grofit包不起作用

[英]R: ylim and xlab/ylab in plot() for grofit package not working

I am trying to plot a growth spline for the variable "ipen" against "year" in this data. 我试图在数据中绘制变量“ ipen”对“ year”的增长样条曲线。 The code I am using is: 我使用的代码是:

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)

This works fine, and produces the plot below. 这可以正常工作,并生成下面的图。 But the problem is that (a) I can't change the default labels with xlab or ylab options, and (b) I can't change the scale of x-axis to be (0,100) with ylim=c(0,100) in the plot() statement. 但是问题在于(a)我无法使用xlabylab选项更改默认标签,并且(b)我无法通过ylim=c(0,100)将x轴的比例更改为ylim=c(0,100) plot()语句。 I could not find any pointers in the grofit() documentation. 我在grofit()文档中找不到任何指针。 这个 .

Don't directly use plot on the gcFitSpline result, but rather use str(growth) to explore the structure of the curve fit object and determine what you want to plot, or look at plot.gcFitSpline code (just type the name of the function without parentheses in the console and press Enter!) 不要在gcFitSpline结果上直接使用plot ,而要使用str(growth)探索曲线拟合对象的结构并确定要绘制的内容,或者查看plot.gcFitSpline代码(只需键入函数的名称)在控制台中不带括号,然后按Enter!)

For instance: 例如:

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)

This gives: 这给出:

结果grofit图

Actually, I think the grofit documentation does have a pointer about this: 实际上,我认为grofit文档确实对此有一个指示:

... Other graphical parameters may also passed as arguments [sic]. ...其他图形参数也可以作为参数传递[sic]。 This has currently no effect and is only meant to fulfill the requirements of a generic function. 目前这没有效果,仅是为了满足通用功能的要求。

You may have to rewrite the plot.gcFitSpline function specific to the graphical parameters you want, but there might be a reason that the function is the way it is. 您可能需要重写特定于所需图形参数的plot.gcFitSpline函数,但是可能有一个原因,就是该函数的样子。

BTW, I'm not sure it's a great idea to give your data the same name as the package you're using. 顺便说一句,我不确定给您的数据和您使用的包同名是个好主意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM