customLayout v0.1.0

0

Monthly downloads

0th

Percentile

Extended Version of Layout Functionality for 'Base' and 'Grid' Graphics Systems

Create complicated drawing areas for multiple plots by combining much simpler layouts. It is an extended version of layout function from the 'graphics' package, but it also works with 'grid' graphics.

Readme

customLayout

GitHub
stars GitHub
watchers

CRAN\_Status\_Badge Downloads Travis-CI Build
Status AppVeyor Build
Status Coverage
Status Project Status: Active - The project has reached a stable, usable
state and is being actively
developed.

customLayout is a simple extension of the basic layout function from R.

Instalation:

customLayout is available only via GitHub and can be installed using devtools:

require(devtools)
install_github("customLayout",username="zzawadz")

Basic functionality:

You can create layouts in the using the same syntax as in the base layout function:

library(customLayout)
lay <- layCreate(
  matrix(1:4, nc = 2),
  widths = c(3, 2),
  heights = c(2, 1))
layShow(lay)


lay2 <- layCreate(
  matrix(1:4, nc = 2),
  widths = c(3, 5),
  heights = c(2, 4))
layShow(lay2)

But the main strength of this package is in combining created layouts with specific ratio:

# lay will be 3 times wider that lay2
# all ascects in lay and lay2 will be preserved
cl = layColBind(lay, lay2, widths = c(3, 1))
layShow(cl)

You can create even more complicated layouts:

lay3 <- layCreate(matrix(1:2))
lay4 <- layRowBind(cl, lay3, heights = c(5, 2))
layShow(lay4)


lay5 <- layColBind(lay4, lay3, widths = c(5, 2))
layShow(lay5)

Split layout

You can create very complicated layouts by splitting one field:

library(customLayout)
lay <- layCreate(
  matrix(1:4, nc = 2),
  widths = c(3, 2),
  heights = c(2, 1))
layShow(lay)

lay2 <- layCreate(
  matrix(1:4, nc = 2),
  widths = c(3, 5),
  heights = c(2, 4))
layShow(lay2)


# Split field 4 from lay into lay2:
slay <- laySplitField(lay, lay2, field = 4)
layShow(slay)

Example session:

Base graphics

library(customLayout)
par(mar = c(3, 2, 2, 1))
lay  <- layCreate(
  matrix(1:4, nc = 2),
  widths = c(3, 2),
  heights = c(2, 1))
lay2 <- layCreate(matrix(1:3))
cl   <- layColBind(lay, lay2, widths = c(3, 1))

laySet(cl) # initialize drawing area

set.seed(123)
plot(1:100 + rnorm(100))
plot(rnorm(100), type = "l")
hist(rnorm(500))
acf(rnorm(100))
pie(c(3, 4, 6), col = 2:4)
pie(c(3, 2, 7), col = 2:4 + 3)
pie(c(5, 4, 2), col = 2:4 + 6)

Grid graphics (ggplot2 and friends)

library(customLayout)
library(ggplot2)
library(gridExtra)

lay  <- layCreate(
  matrix(1:2, ncol = 1))
lay2 <- layCreate(matrix(1:3))
cl   <- layColBind(lay, lay2, widths = c(3, 1))


library(ggplot2)
cuts <- sort(unique(diamonds[["cut"]]),
            decreasing = TRUE)

make_cut_plot <- function(cut) {
  dd <- diamonds[diamonds[["cut"]] == cut, ]
  pl <- ggplot(dd) +
      geom_point(aes(carat, price)) +
      facet_wrap("cut")
  pl
}

plots <- lapply(cuts, make_cut_plot)

layGrid(plots, cl)

Functions in customLayout

Name Description
layColBind Take two Layout objects and combine by rows.
layCreate Create custom layout.
laySplitField Split a selected field from layout using a schema from another layout.
layRowBind Take two Layout objects and combine by rows.
layGrid Use Layout object with grid graphics.
laySet Set custom layout.
layShow Print the layout structure to the graphical device.
No Results!

Last month downloads

Details

Type Package
License GPL-3
RoxygenNote 6.1.0
URL https://www.customlayout.zstat.pl/, https://github.com/zzawadz/customLayout
BugReports https://github.com/zzawadz/customLayout/issues
NeedsCompilation no
Packaged 2018-09-11 07:53:32 UTC; zzawadz
Repository CRAN
Date/Publication 2018-09-12 15:10:18 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/customLayout)](http://www.rdocumentation.org/packages/customLayout)