Home > Software design >  How can I customize a loess fit inside a levelplot in R
How can I customize a loess fit inside a levelplot in R

Time:06-26

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: enter image description here

Now let's use a smaller span value for our loess smoothing:

levelplot(Sepal.Width ~ Petal.Width * Petal.Length, 
          iris,
          region = TRUE, 
          col.regions = hcl.colors(110, palette = "spectral", rev = F), 
          contour = FALSE)  
  layer_(panel.2dsmoother(..., n = 400, method = 'loess', 
                         args = list(span = 0.2)))

enter image description here

  • Related