Learn R Programming

loon.ggplot (version 1.1.0)

loon.ggplot: loon.ggplot

Description

A bridge between loon widgets and gg objects. It can take either a loon widget, a gg object (ggplot or GGally::ggmatrix) or a lggplot object, then create a corresponding gg (or loon) graphics.

Usage

loon.ggplot(x, ...)

# S3 method for gg loon.ggplot(x, ...)

# S3 method for loon loon.ggplot(x, ...)

# S3 method for lggplot loon.ggplot(x, ...)

Arguments

x

A loon widget, a ggplot object or a lggplot object.

...

arguments used in either loon2ggplot() or ggplot2loon()

Value

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 lggplot object, loon.ggplot helps to return a loon widget.

See Also

loon2ggplot, ggplot2loon, l_ggplot

Examples

Run this code
# NOT RUN {
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

######### lggplot #########
  p <- l_ggplot(mpg, aes(displ, fill = factor(cyl))) +
       geom_histogram()
  class(p)
  # Function `print.lggplot` is called automatically
  p
  # Function `loon.ggplot` helps to return a loon widget
  q <- loon.ggplot(p)
  q
}
# }

Run the code above in your browser using DataLab