loon.ggplot | R Documentation |
A bridge between loon
widgets and gg
objects. It can take either a loon
widget,
a gg
object (ggplot
, GGally::ggmatrix
) or
a l_ggplot
object, then create a corresponding gg
(or loon
) graphics.
loon.ggplot(x, ...) ## S3 method for class 'gg' loon.ggplot(x, ...) ## S3 method for class 'loon' loon.ggplot(x, ...) ## S3 method for class 'zenplot' loon.ggplot(x, ...) ## S3 method for class 'l_ggplot' loon.ggplot(x, ...)
x |
A |
... |
arguments used in either |
If the input is a ggplot
object, the output would be a loon
widget; conversely, if the
input is a loon
widget, then it returns a ggplot
object. If it is a l_ggplot
object,
loon.ggplot
helps to return a loon
widget.
Richer examples are in loon2ggplot
, ggplot2loon
, l_ggplot
if(interactive()) { ######### loon --> gg ######### # loon 3D plot l <- with(quakes, l_plot3D(long, lat, depth, linkingGroup = "quakes") ) # equivalent to `loon2ggplot(l)` g <- loon.ggplot(l) g # a ggplot object ######### gg --> loon ######### # ggplot histogram g <- ggplot(iris, mapping = aes(Sepal.Length, fill = Species)) + geom_histogram() # equivalent to `ggplot2loon(g)` l <- loon.ggplot(g) l # a loon widget ######### l_ggplot ######### p <- l_ggplot(mpg, aes(displ, fill = factor(cyl))) + geom_histogram() class(p) # Function `print.l_ggplot` is called automatically p # Function `loon.ggplot` helps to return a loon widget q <- loon.ggplot(p) q }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.