我在R中创建了一个LevelPlot,它使用此代码显示了我的数据叠加在平滑轮廓图上的数据:
levelplot(chla_avg ~ lat * depth, trunc_level_test, ylim = c(275, 5), region = TRUE, col.regions = hcl.colors(110, palette = "spectral",rev=F), contour = FALSE, cuts = 100, panel = panel.levelplot.points) +
layer_(panel.2dsmoother(..., n = 400, method = 'loess'))
这会产生此图像:
levelplot
我喜欢这张图。它完全显示了我想要的 ,我不喜欢黄土模型的合适。正常我可以自定义 loess()
,但我无法弄清楚如何获得 panel.2dsmoother()
来获取我的参数。理想情况下,我想更改 span
和度
loess()
的参数,以使拟合度降低一点。
我已经尝试过:
levelplot(chla_avg ~ lat * depth, trunc_level_test, ylim = c(275, 5), region = TRUE, col.regions = hcl.colors(110, palette = "spectral",rev=F), contour = FALSE, cuts = 100, panel = panel.levelplot.points) +
layer_(panel.2dsmoother(..., n = 400, method = 'loess(span=0.1)'))
哪个产生此错误:
Error using packet 1
could not find function "loess(span=0.1)"
清楚面板。2DDSMOOTHER
正在以我不理解的方式重新解释该功能。
在 panel.2DSMOOTHOR
文档中说:“平滑模型是构建(大约)为方法(form,data = list = list(x = x,y = y,z = z), {args})
。” ( loess 函数。
无论如何,是否可以在 panel内部自定义黄土。2DDSMOOTHOR
?
I have created a levelplot in R that displays my data overlayed on a smoother contour plot using this code:
levelplot(chla_avg ~ lat * depth, trunc_level_test, ylim = c(275, 5), region = TRUE, col.regions = hcl.colors(110, palette = "spectral",rev=F), contour = FALSE, cuts = 100, panel = panel.levelplot.points) +
layer_(panel.2dsmoother(..., n = 400, method = 'loess'))
This produces this image:
levelplot
I love this graph. It displays exactly what I want except I don't love the fit of the loess model. Normal I could customize loess()
but I can't figure out how to get panel.2dsmoother()
to take my arguments. Ideally I would like to change the span
and degree
arguments of loess()
to make the fit a little less smooth.
I've tried:
levelplot(chla_avg ~ lat * depth, trunc_level_test, ylim = c(275, 5), region = TRUE, col.regions = hcl.colors(110, palette = "spectral",rev=F), contour = FALSE, cuts = 100, panel = panel.levelplot.points) +
layer_(panel.2dsmoother(..., n = 400, method = 'loess(span=0.1)'))
Which produces this error:
Error using packet 1
could not find function "loess(span=0.1)"
Clearly panel.2dsmoother
is reinterpreting the function in a way I do not understand.
In the panel.2dsmoother
documentation it says: "the smoothing model is constructed (approximately) as method(form, data = list(x=x, y=y, z=z), {args})
." (panel.2dsmoother documentation) I cannot figure out how to pass my arguments to the loess
function.
Is there anyway to customize loess inside panel.2dsmoother
?
发布评论
评论(1)
您可以使用
args
panel.2dsmoother
的参数将额外的参数传递到loess
方法。只需将参数放入列表
中即可。显然,我们没有您的数据,但是我们可以使用内置数据集
iris
来显示概念。首先,我们将以默认参数向图显示:现在让我们使用较小的
span
为我们的羊皮平滑值:You can pass extra arguments to the
loess
method using theargs
parameter ofpanel.2dsmoother
. Just put the arguments inside alist
.Obviously, we don't have your data, but we can show the concept using the built in data set
iris
. First, we'll show the plot with the default arguments:Now let's use a smaller
span
value for our loess smoothing: