2014-10-01 63 views
1

我正在尝试将线性趋势线添加到已被平滑的散点图panel.smoothScatter将panel.lmline和panel.smoothScatter添加到格xyplot中

基于其他职位,我尝试添加type=c("p","r"),但这没有做什么。我也试图使面板调用以下两种功能,但是这会导致一个空白的情节:

#plots smoothed scatter without trend line 
p2 <- xyplot(y~x, grid=T, type=c("p","r"), panel=panel.smoothScatter) 
#plots nothing 
p2 <- xyplot(y~x, grid=T, type=c("p","r"), panel=function(...){panel.smoothScatter;panel.lmline}) 

我怎样才能在一个xyplot panels使用多个?

回答

3

你只需要修复您的自定义面板功能实际调用所需面板功能正常

p2 <- xyplot(y~x, grid=T, panel=function(...){ 
    panel.smoothScatter(...) 
    panel.lmline(...) 
}) 
+1

你太快了我! – 2014-10-01 19:56:02