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 gg
loon.ggplot(x, ...)
# S3 method for loon
loon.ggplot(x, ...)
# S3 method for zenplot
loon.ggplot(x, ...)
# S3 method for l_ggplot
loon.ggplot(x, ...)
A loon
widget, a ggplot
object or a l_ggplot
object.
arguments used in either loon2ggplot()
or ggplot2loon()
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
}