Commit b125a52e authored by Andreas Tille's avatar Andreas Tille

New upstream version 0.4-7

parent a7f6d5cb
Package: gridBase
Title: Integration of base and grid graphics
Version: 0.4-7
Author: Paul Murrell
Depends: R (>= 2.3.0)
Imports: graphics, grid
Suggests: lattice
Description: Integration of base and grid graphics
Maintainer: Paul Murrell <paul@stat.auckland.ac.nz>
License: GPL
Packaged: 2014-02-24 01:35:23 UTC; EC\pmur002
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2014-02-24 07:20:37
6357f2ece12d167c6edfc70a9efe76d7 *DESCRIPTION
c23517ab9923f0ec0d87802ff359413a *NAMESPACE
519be1dbab635db1db865c24cc09dfba *R/base.R
921e99fcb1c256cd1f6ad6475d7dc737 *R/grid.R
0433ce02f1d7d8db515c259aabb64f1b *R/zzz.R
f4d0a523b792fe11d3d89aa1ed8dc50e *build/vignette.rds
97c6d4a0460b64a8e6ac40a24cddb33c *demo/00Index
b0f31e33f859785fb0058f30dd3bcbb6 *demo/gridBase.R
bc3aecdea068b8689e959dc5464b2ecb *inst/doc/changes.txt
444f2b1f2d8472ae45c05d9f86321e46 *inst/doc/chinasea.txt
04bf5e05f35567c9233a8874af544daf *inst/doc/gridBase.R
7d84d0cdabfa9877c817064d35ca47b6 *inst/doc/gridBase.Rnw
df58ed5b9c51efa05f0de0f6ad12a429 *inst/doc/gridBase.pdf
1cb988e34f020de26f286dc9684e2ebc *man/baseViewports.Rd
dd062f90a9221e7f2a1241cb9fbbddc1 *man/gridOMI.Rd
7d84d0cdabfa9877c817064d35ca47b6 *vignettes/gridBase.Rnw
6506cce9c6756dc2b0e4f061542f2404 *vignettes/gridBase.bib
importFrom(graphics,
par)
importFrom(grid,
unit, viewport,
convertHeight, convertWidth, current.transform, get.gpar)
export("baseViewports",
"gridOMI", "gridFIG", "gridPLT", "gridPAR")
# Generate a list of viewports that correspond to the current base
# inner region, figure region, and plot region
baseViewports <- function() {
omi <- par("omi")
innervp <- viewport(x=unit(omi[2], "inches"),
y=unit(omi[1], "inches"),
width=unit(1, "npc") -
unit(omi[1], "inches") -
unit(omi[3], "inches"),
height=unit(1, "npc") -
unit(omi[2], "inches") -
unit(omi[4], "inches"),
just=c("left", "bottom"))
fig <- par("fig")
figurevp <- viewport(x=unit(fig[1], "npc"),
y=unit(fig[3], "npc"),
width=unit(fig[2] - fig[1], "npc"),
height=unit(fig[4] - fig[3], "npc"),
just=c("left", "bottom"))
plt <- par("plt")
usr <- par("usr")
logscale <- FALSE
if (par("xlog") || par("ylog")) {
warning("viewport scales NOT set to user coordinates")
logscales <- TRUE
}
plotvp <- viewport(x=unit(plt[1], "npc"),
y=unit(plt[3], "npc"),
width=unit(plt[2] - plt[1], "npc"),
height=unit(plt[4] - plt[3], "npc"),
just=c("left", "bottom"),
xscale=c(usr[1], usr[2]),
yscale=c(usr[3], usr[4]))
list(inner=innervp, figure=figurevp, plot=plotvp)
}
# Get the location/size of the current viewport in inches on the device
currentViewportLoc <- function() {
# Get the current viewport transformation
# This transforms from inches in the current viewport to
# inches on the device
transform <- current.transform()
# Convert the current viewport's location to inches ...
width <- convertWidth(unit(1, "npc"), "inches", valueOnly=TRUE)
height <- convertHeight(unit(1, "npc"), "inches", valueOnly=TRUE)
# ... then to inches on the device
bottomleft <- c(0, 0, 1) %*% transform
left <- bottomleft[1]/bottomleft[3]
bottom <- bottomleft[2]/bottomleft[3]
topright <- c(width, height, 1) %*% transform
right <- topright[1]/topright[3]
top <- topright[2]/topright[3]
list(left=left, bottom=bottom, right=right, top=top)
}
# Prolific use of round(..., digits=4) because lots of the time
# calculated values will be intended to be the same, but will
# differ by tiny amounts due to rounding error. In particular,
# we are keen to avoid getting tiny negative values for par()
# settings. digits=4 because with the values we are dealing with
# two decimal places is plenty of precision.
# Check that a viewport location is within base outer margin setting
badOMI <- function(cvp, omi, din) {
round(cvp$left - omi[2], digits=4) < 0 ||
round(cvp$bottom - omi[1], digits=4) < 0 ||
round(cvp$right - (din[1] - omi[4]), digits=4) > 0 ||
round(cvp$top - (din[2] - omi[3]), digits=4) > 0
}
# Check that a viewport location is within base figure region setting
badFIG <- function(cvp, fig, omi, din) {
width <- din[1] - omi[2] - omi[4]
height <- din[2] - omi[1] - omi[3]
round(cvp$left - (omi[2] + fig[1]*width), digits=4) < 0 ||
round(cvp$bottom - (omi[1] + fig[3]*height), digits=4) < 0||
round(cvp$right - (omi[2] + fig[2]*width), digits=4) > 0 ||
round(cvp$top - (omi[1] + fig[4]*height), digits=4) > 0
}
# Return par(omi) settings that correspond to the current
# grid viewport
gridOMI <- function() {
# First get the current viewport locn/size
cvp <- currentViewportLoc()
# return outer margin values
din <- par("din")
# Do a round to avoid rounding error
omi <- round(c(cvp$bottom, cvp$left,
din[2] - cvp$top, din[1] - cvp$right), digits=4)
omi
}
# Return par(fig) settings that correspond to the current
# grid viewport
gridFIG <- function() {
# First get the current viewport locn/size
cvp <- currentViewportLoc()
# Get the current base outer margins (in inches)
din <- par("din")
omi <- par("omi")
# Throw an error if the curent viewport is outside the
# current outer margins (implies fig values outside [0, 1] range)
if (badOMI(cvp, omi, din))
stop("Outer margins too large and/or viewport too large")
# par(fig) is proportions within the inner region
# par(fig) is c(x1, x2, y1, y2)
width <- din[1] - omi[2] - omi[4]
height <- din[2] - omi[1] - omi[3]
# Do a round to avoid rounding error
fig <- round(c((cvp$left - omi[1])/width,
(cvp$right - omi[1])/width,
(cvp$bottom - omi[2])/height,
(cvp$top - omi[2])/height), digits=4)
fig
}
# Return par(plt) settings that correspond to the current
# grid viewport
gridPLT <- function() {
# First get the current viewport locn/size
cvp <- currentViewportLoc()
# Get the current base outer margins (in inches)
# and the current base figure region (as a proportion of the inner region)
din <- par("din")
omi <- par("omi")
fig <- par("fig")
# Throw an error if the curent viewport is outside the
# current figure region (implies plt values outside [0, 1] range)
if (badFIG(cvp, fig, omi, din))
stop("Figure region too small and/or viewport too large")
# par(plt) is proportions within the figure region
# par(plt) is c(x1, x2, y1, y2)
innerwidth <- din[1] - omi[2] - omi[4]
innerheight <- din[2] - omi[1] - omi[3]
width <- innerwidth*(fig[2] - fig[1])
height <- innerheight*(fig[4] - fig[3])
left <- omi[2] + innerwidth*fig[1]
bottom <- omi[1] + innerheight*fig[3]
# Do a round to avoid rounding error
plt <- round(c((cvp$left - left)/width,
(cvp$right - left)/width,
(cvp$bottom - bottom)/height,
(cvp$top - bottom)/height), digits=4)
plt
}
# Return some gpar settings that can be used to set par() graphical
# parameters
gridPAR <- function() {
gpars <- get.gpar()
# FIXME: Need to add font specifications too
gpars <- list(col=gpars$col,
lwd=gpars$lwd,
lty=gpars$lty)
}
.onLoad <- function(lib, pkg)
{
}
Notes on how this package can be tested.
────────────────────────────────────────
To run the unit tests provided by the package you can do
sh run-unit-test
in this directory.
r-cran-gridbase (0.4-7-2) unstable; urgency=medium
* added CI test deps (thanks to Gordon Ball)
-- Andreas Tille <tille@debian.org> Sat, 30 Jul 2016 22:32:26 +0200
r-cran-gridbase (0.4-7-1) unstable; urgency=low
* Initial release (closes: #830197)
-- Andreas Tille <tille@debian.org> Thu, 07 Jul 2016 12:48:41 +0200
Source: r-cran-gridbase
Maintainer: Debian Med Packaging Team <debian-med-packaging@lists.alioth.debian.org>
Uploaders: Andreas Tille <tille@debian.org>
Section: gnu-r
Priority: optional
Build-Depends: debhelper (>= 9),
cdbs,
r-base-dev,
Standards-Version: 3.9.8
Vcs-Browser: https://anonscm.debian.org/viewvc/debian-med/trunk/packages/R/r-cran-gridbase/trunk/
Vcs-Svn: svn://anonscm.debian.org/debian-med/trunk/packages/R/r-cran-gridbase/trunk/
Homepage: https://cran.r-project.org/web/packages/gridBase
Package: r-cran-gridbase
Architecture: all
Depends: ${misc:Depends},
${R:Depends},
Description: GNU R Integration of base and grid graphics
This GNU R package enables integration of base and grid graphics.
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: gridBase
Upstream-Contact: Paul Murrell <paul@stat.auckland.ac.nz>
Source: https://cran.r-project.org/web/packages/gridBase
Files: *
Copyright: 2012-2014 Paul Murrell <paul@stat.auckland.ac.nz>
License: GPL-2+
Comment: The download page specifies
GPL-2 | GPL-3 [expanded from: GPL] and links to a GPL-2+ text
Files: debian/*
Copyright: 2016 Andreas Tille <tille@debian.org>
License: GPL-2+
License: GPL-2+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
On Debian systems, the complete text of the GNU General Public
License can be found in `/usr/share/common-licenses/GPL-2'.
debian/README.test
debian/tests/run-unit-test
#!/usr/bin/make -f
include /usr/share/R/debian/r-cran.mk
Tests: run-unit-test
Depends: @, r-cran-lattice
Restrictions: allow-stderr
#!/bin/sh -e
oname=gridBase
pkg=r-cran-`echo $oname | tr '[A-Z]' '[a-z]'`
if [ "$ADTTMP" = "" ] ; then
ADTTMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
# trap "rm -rf $ADTTMP" 0 INT QUIT ABRT PIPE TERM
fi
cd $ADTTMP
cp /usr/share/doc/$pkg/examples/vignettes/* $ADTTMP
find . -name "*.gz" -exec gunzip \{\} \;
for rnw in `ls *.[rRS]nw` ; do
rfile=`echo $rnw | sed 's/\.[rRS]nw/.R/'`
R --no-save <<EOT
Stangle("$rnw")
source("$rfile", echo=TRUE)
EOT
echo "$rnw passed"
done
version=3
http://cran.r-project.org/src/contrib/gridBase_([-\d.]*)\.tar\.gz
gridBase Demo of integrating grid and base graphics
# A base plot with grid viewports synchronised then
# further grid viewports pushed to contain pie charts
x <- runif(4)
y <- runif(4)
z <- matrix(runif(4*2), ncol=2)
maxpiesize <- unit(1, "inches")
totals <- apply(z, 1, sum)
sizemult <- totals/max(totals)
oldomi <- par("omi")
plot(x, y, xlim=c(-0.2, 1.2), ylim=c(-0.2, 1.2), type="n")
vps <- baseViewports()
# First grid action will trigger a new page unless we do this
# Should be able to avoid this yuckiness in the future
par(new=TRUE)
pushViewport(vps$inner, vps$figure, vps$plot)
grid.grill(h=y, v=x, default.units="native")
for (i in 1:4) {
pushViewport(viewport(x=unit(x[i], "native"),
y=unit(y[i], "native"),
width=sizemult[i]*maxpiesize,
height=sizemult[i]*maxpiesize))
grid.rect(gp=gpar(col="grey", fill="white", lty="dashed"))
par(mar=rep(0, 4), omi=gridOMI(), new=TRUE)
pie(z[i,], radius=1, labels=rep("", 2))
popViewport()
}
popViewport(3)
par(omi=rep(0, 4), mar=c(5.1, 5.1, 4.1, 2.1))
FROM gridBase_0.4-6 TO gridBase_0.4-7
-------------------------------------
1. Changed to ONLY using Imports for 'grid' and 'graphics'
(no longer Depends on these)
(to satisfy stricter R CMD check)
FROM gridBase_0.4-5 TO gridBase_0.4-6
-------------------------------------
1. Changed to using Imports from 'grid' in NAMESPACE rather than
just Depending on 'grid'. Ditto for 'graphics'.
This allows other packages to Import 'gridBase' without
having to attach 'gridBase' to the search path.
(Thanks to Martin Maechler for the suggestion and patches)
FROM gridBase_0.4 TO gridBase_0.4-1
-----------------------------------
1. Updated demo(gridBase)
Was using very old gridOMI() behaviour which actually set par(omi)
rather than just returning a value to use in a call to par()
Date Time Date2 Time2 CSEId name id lat long elev press temp dew rhum shum speed dir u v rain snow sflux lflux isr osr ilr olr rad skin co2 inpar outpar
2001/07/01 00:00 2001/07/01 00:00 CAMP 46759 Hengchun 22.00000 120.74000 22.10 1006.80 28.90 25.40 81.00 20.29 4.70 90.00 -4.70 0.00 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46762 Lanyu 22.04000 121.55000 324.00 974.10 27.10 25.50 91.00 21.10 7.60 90.00 -7.60 0.00 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46754 Tawu 22.36000 120.90000 8.10 1009.80 27.90 25.40 86.00 20.23 0.90 30.00 -0.45 -0.78 0.60 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46744 Kaohsiung 22.57000 120.31000 2.30 1007.50 31.20 24.00 66.00 18.63 4.60 160.00 -1.57 4.32 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46766 Taitung 22.75000 121.15000 9.00 1009.90 30.80 21.80 59.00 16.24 0.50 320.00 0.32 -0.38 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46741 Tainan 23.00000 120.20000 13.80 1006.50 30.50 26.20 78.00 21.29 0.10 0.00 0.00 -0.10 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46761 Chengkung 23.10000 121.37000 33.50 1006.10 30.60 24.30 69.00 19.00 1.30 200.00 0.44 1.22 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46730 Tungchitao 23.26000 119.66000 45.00 1003.20 30.10 23.90 69.00 18.60 3.20 80.00 -3.15 -0.56 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46755 Yushan 23.49000 120.95000 3845.00 644.80 8.60 -2.70 45.00 4.84 14.00 130.00 -10.72 9.00 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46748 Chiayi 23.50000 120.42000 26.90 1004.50 29.30 24.40 75.00 19.14 0.70 40.00 -0.45 -0.54 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46753 Alishan 23.51000 120.80000 2413.00 764.30 18.40 9.50 56.00 9.72 0.90 10.00 -0.16 -0.89 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46735 Penghu 23.57000 119.56000 10.70 1007.00 31.20 26.40 76.00 21.54 1.30 100.00 -1.28 0.23 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46765 Jiyuehtan 23.88000 120.90000 1015.00 899.60 24.70 20.00 75.00 16.33 0.10 0.00 0.00 -0.10 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46699 Hualien 23.98000 121.60000 16.10 1007.90 29.70 22.40 65.00 16.89 5.80 230.00 4.44 3.73 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46749 Taichung 24.15000 120.68000 84.00 998.40 29.30 24.50 75.00 19.38 0.50 190.00 0.09 0.49 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46777 Wuchi 24.26000 120.52000 7.20 1005.50 29.50 24.20 73.00 18.89 1.70 40.00 -1.09 -1.30 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46706 Suao 24.60000 121.86000 24.90 1006.10 31.30 21.50 56.00 16.01 5.10 170.00 -0.89 5.02 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46708 Ilan 24.77000 121.75000 7.20 1007.60 30.50 24.30 70.00 18.97 1.50 50.00 -1.15 -0.96 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46757 Hsinchu 24.83000 121.01000 26.90 1005.20 29.20 25.10 79.00 19.96 0.30 90.00 -0.30 0.00 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46692 Taipei 25.03000 121.52000 8.00 1007.60 29.80 22.90 67.00 17.42 0.30 240.00 0.26 0.15 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46694 Keelung 25.13000 121.73000 26.70 1005.20 30.30 24.80 72.00 19.60 2.20 40.00 -1.41 -1.69 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46693 Chutzehu 25.16000 121.54000 607.00 941.80 25.00 22.10 84.00 17.76 0.60 340.00 0.21 -0.56 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46690 Tanshui 25.17000 121.43000 19.00 1006.00 29.30 25.80 81.00 20.80 0.70 280.00 0.69 -0.12 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46691 Anpu 25.18000 121.52000 837.60 918.20 24.10 22.30 90.00 18.44 2.90 350.00 0.50 -2.86 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
2001/07/01 00:00 2001/07/01 00:00 CAMP 46695 Pengchiayu 25.63000 122.07000 99.00 997.20 28.20 24.80 82.00 19.76 13.10 150.00 -6.55 11.34 0.00 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99 -999.99
This diff is collapsed.
This diff is collapsed.
\name{baseViewports}
\alias{baseViewports}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{ Generate grid Viewports from Base Plot }
\description{
This will generate a list of grid viewports which correspond
to the current inner, figure, and plot regions of the current
base plot.
}
\usage{
baseViewports()
}
\details{
The figure region is relative to the inner region so you
must push the inner region before pushing the figure region.
Similarly, the plot region is relative to the figure region
so this should only be pushed after the previous two.
}
%- maybe also 'usage' for other objects documented here.
\value{
A list with three elements:
\item{inner }{A viewport corresponding to the inner region
of the current plot.}
\item{figure }{A viewport corresponding to the figure region
of the current plot.}
\item{plot }{A viewport corresponding to the plot region
of the current plot.}
}
\author{ Paul Murrell }
\section{Warning}{ If you resize the device, all bets are off! }
\seealso{ \link{Grid}, \code{\link{viewport}} }
\examples{
library(grid)
par(oma=rep(1, 4), mfrow=c(1, 2), xpd=NA)
plot(1:10)
vps <- baseViewports()
pushViewport(vps$inner)
grid.rect(gp=gpar(lwd=3, col="red"))
pushViewport(vps$figure)
grid.rect(gp=gpar(lwd=3, col="green"))
pushViewport(vps$plot)
grid.rect(gp=gpar(lwd=3, col="blue"))
grid.points(1:10, 10:1)
}
\keyword{ dplot }% at least one, from doc/KEYWORDS
\name{Set Base Plot Regions}
\alias{gridOMI}
\alias{gridFIG}
\alias{gridPLT}
\alias{gridPAR}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{ Set Base Plotting Regions from Grid Viewport }
\description{
These functions can be used to align base plotting regions
with the current grid
viewport. This can be used to draw base plots within a grid viewport.
}
\usage{
gridOMI()
gridFIG()
gridPLT()
gridPAR()
}
\details{
For this to be useful, you will have to make liberal use of
\code{par(new=TRUE)} to prevent base from moving to a new page.
With care, these can even be used to draw multiple base plots within
a grid viewport (see the examples below), but in general, base
plotting functions that draw multiple panels (e.g., \code{coplot})
should not be
expected to work.
}
%- maybe also 'usage' for other objects documented here.
\value{
\code{gridOMI} returns a value that can be used to set the
\code{par(omi)} parameter.
\code{gridFIG} returns a value that can be used to set the
\code{par(fig)} parameter.
\code{gridPLT} returns a value that can be used to set the
\code{par(plt)} parameter.
\code{gridPAR} returns a value that can be used to set
some graphical parameters (currently, \code{lwd}, \code{lty},
and \code{col}).
}
\author{ Paul Murrell }
\section{Warning}{ If you resize the device, all bets are off! }
\seealso{ \link{Grid}, \code{\link{viewport}} }
\examples{
library(grid)
opar <- par(no.readonly=TRUE)
# gridFIG
grid.newpage()
pushViewport(viewport(width=0.5, height=0.5))
grid.rect(gp=gpar(col="grey", lty="dashed"))
par(fig=gridFIG())
par(new=TRUE)
plot(1:10)
# multiple plots
# NOTE the use of par(mfg)
# gridOMI
par(opar)
grid.newpage()
pushViewport(viewport(width=0.5, height=0.5))
grid.rect(gp=gpar(col="grey", lty="dashed"))
par(omi=gridOMI())
par(mfrow=c(2, 2), mfg=c(1, 1), mar=c(3, 3, 1, 0))
for (i in 1:4) {
plot(i)
}
# gridPLT
par(opar)
grid.newpage()
pushViewport(viewport(width=0.5, height=0.5))
grid.rect(gp=gpar(col="grey", lwd=5))
par(plt=gridPLT())
par(new=TRUE)
plot(1:10)
# gridFIG with par(omi) set
par(opar)
grid.newpage()
par(omi=rep(1, 4))
pushViewport(viewport(width=0.5, height=0.5))
grid.rect(gp=gpar(col="grey", lwd=5))
par(fig=gridFIG())
par(new=TRUE)
plot(1:10)
# gridPLT with par(omi) set
par(opar)
grid.newpage()
par(omi=rep(1, 4))
pushViewport(viewport(width=0.5, height=0.5))
grid.rect(gp=gpar(col="grey", lwd=5))
par(plt=gridPLT())
par(new=TRUE)
plot(1:10)
# gridPAR
par(opar)
grid.newpage()
pushViewport(viewport(width=0.5, height=0.5,
gp=gpar(col="red", lwd=3, lty="dotted")))
grid.rect(gp=gpar(col="grey", lwd=5))
par(fig=gridFIG())
par(gridPAR())
par(new=TRUE)
plot(1:10, type="b")
}
\keyword{ dplot }% at least one, from doc/KEYWORDS
This diff is collapsed.
@Article{Rnews:Murrell:2002,
author = {Paul Murrell},
title = {The grid Graphics Package},
journal = {R News},
year = 2002,
volume = 2,
number = 2,
pages = {14--19},
month = {June},
url = {http://CRAN.R-project.org/doc/Rnews/}
}
@Article{Rnews:Sarkar:2002,
author = {Deepayan Sarkar},
title = {Lattice},
journal = {R News},
year = 2002,
volume = 2,
number = 2,
pages = {19--23},
month = {June},
url = {http://CRAN.R-project.org/doc/Rnews/}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment