l_layer_polygon.Rd
Loon's displays that are based on Cartesian coordinates (i.e. scatterplot, histogram and graph display) allow for layering visual information including polygons, text and rectangles.
l_layer_polygon(widget, x, y, color = "gray80", linecolor = "black", linewidth = 1, label = "polygon", parent = "root", index = 0, ...)
widget | widget path name as a string |
---|---|
x | x coordinates |
y | y coordinates |
color | fill color, if empty string |
linecolor | outline color |
linewidth | linewidth of outline |
label | label used in the layers inspector |
parent | group layer |
index | of the newly added layer in its parent group |
... | additional state initialization arguments, see
|
layer object handle, layer id
For more information run: l_help("learn_R_layer")
set.seed(500) x <- rnorm(30) y <- 4 + 3*x + rnorm(30) fit <- lm(y~x) xseq <- seq(min(x)-1, max(x)+1, length.out = 50) fit_line <- predict(fit, data.frame(x=range(xseq))) ci <- predict(fit, data.frame(x=xseq), interval="confidence", level=0.95) pi <- predict(fit, data.frame(x=xseq), interval="prediction", level=0.95) p <- l_plot(y~x, color='black', showScales=TRUE, showGuides=TRUE) gLayer <- l_layer_group( p, label="simple linear regression", parent="root", index="end" ) fitLayer <- l_layer_line( p, x=range(xseq), y=fit_line, color="#04327F", linewidth=4, label="fit", parent=gLayer ) ciLayer <- l_layer_polygon( p, x = c(xseq, rev(xseq)), y = c(ci[,'lwr'], rev(ci[,'upr'])), color = "#96BDFF", linecolor="", label = "95 % confidence interval", parent = gLayer, index='end' ) piLayer <- l_layer_polygon( p, x = c(xseq, rev(xseq)), y = c(pi[,'lwr'], rev(pi[,'upr'])), color = "#E2EDFF", linecolor="", label = "95 % prediction interval", parent = gLayer, index='end' ) l_info_states(piLayer)#> $x #> $x$type #> [1] "double" #> #> $x$dimension #> [1] "n" #> #> $x$defaultvalue #> [1] "" #> #> $x$description #> [1] "x coordinates" #> #> #> $y #> $y$type #> [1] "double" #> #> $y$dimension #> [1] "n" #> #> $y$defaultvalue #> [1] "" #> #> $y$description #> [1] "y coordinates" #> #> #> $tag #> $tag$type #> [1] "string" #> #> $tag$dimension #> [1] "any" #> #> $tag$defaultvalue #> [1] "" #> #> $tag$description #> [1] "tags useful for item bindings" #> #> #> $itemLabel #> $itemLabel$type #> [1] "string" #> #> $itemLabel$dimension #> [1] "any" #> #> $itemLabel$defaultvalue #> [1] "item" "label" #> #> $itemLabel$description #> [1] "?" #> #> #> $color #> $color$type #> [1] "colorOrTransparent" #> #> $color$dimension #> [1] "1" #> #> $color$defaultvalue #> [1] "" #> #> $color$description #> [1] "fill color of polygon" #> #> #> $linecolor #> $linecolor$type #> [1] "colorOrTransparent" #> #> $linecolor$dimension #> [1] "1" #> #> $linecolor$defaultvalue #> [1] "steelblue" #> #> $linecolor$description #> [1] "outline color of polygon" #> #> #> $linewidth #> $linewidth$type #> [1] "positive_double" #> #> $linewidth$dimension #> [1] "1" #> #> $linewidth$defaultvalue #> [1] "1" #> #> $linewidth$description #> [1] "linewidth of outline" #> #>