70 lines
2.1 KiB
Plaintext
70 lines
2.1 KiB
Plaintext
|
% File src/library/grid/vignettes/moveline.Rnw
|
||
|
% Part of the R package, https://www.R-project.org
|
||
|
% Copyright 2001-13 Paul Murrell and the R Core Team
|
||
|
% Distributed under GPL 2 or later
|
||
|
|
||
|
\documentclass[a4paper]{article}
|
||
|
%\VignetteIndexEntry{Demonstrating move-to and line-to}
|
||
|
%\VignettePackage{grid}
|
||
|
\newcommand{\code}[1]{\texttt{#1}}
|
||
|
\newcommand{\pkg}[1]{{\normalfont\fontseries{b}\selectfont #1}}
|
||
|
\newcommand{\grid}{\pkg{grid}}
|
||
|
\newcommand{\R}{{\sffamily R}}
|
||
|
\setlength{\parindent}{0in}
|
||
|
\setlength{\parskip}{.1in}
|
||
|
\setlength{\textwidth}{140mm}
|
||
|
\setlength{\oddsidemargin}{10mm}
|
||
|
\title{Drawing Lines Between Viewports: \\
|
||
|
\code{grid.move.to} and \code{grid.line.to}}
|
||
|
\author{Paul Murrell}
|
||
|
|
||
|
\begin{document}
|
||
|
\maketitle
|
||
|
|
||
|
<<echo=FALSE, results=hide>>=
|
||
|
library(grDevices)
|
||
|
library(grid)
|
||
|
ps.options(pointsize = 12)
|
||
|
options(width = 60)
|
||
|
@
|
||
|
|
||
|
Many graphics systems have the notion of a current drawing location.
|
||
|
This has been added to Grid, with the additional benefit that the
|
||
|
drawing location can be specified relative to an arbitrary viewport.
|
||
|
This allows drawing across coordinate
|
||
|
systems\footnote{There was a request on R-help for exactly this
|
||
|
sort of thing - I will try to find the exact reference - and there has
|
||
|
since been another (From: Ross Darnell; Subject: Problems with
|
||
|
segments and multiple graphs). }.
|
||
|
|
||
|
The following code demonstrates a simple example (the output is
|
||
|
given after the code).
|
||
|
|
||
|
<<fig, results=hide, fig=TRUE, width=5, height=4, include=FALSE>>=
|
||
|
pushViewport(
|
||
|
viewport(w = 0.8, h = 0.8,
|
||
|
layout = grid.layout(1, 3,
|
||
|
widths = unit(rep(1, 3),
|
||
|
c("null", "inches", "null")))))
|
||
|
pushViewport(viewport(layout.pos.col = 1, yscale = c(0, 4)))
|
||
|
grid.grill(); grid.yaxis(); grid.xaxis()
|
||
|
grid.points(0.5, unit(2, "native"))
|
||
|
grid.move.to(0.5, unit(2,"native"))
|
||
|
popViewport()
|
||
|
pushViewport(viewport(layout.pos.col = 3, yscale = c(0, 2)))
|
||
|
grid.grill(); grid.yaxis(); grid.xaxis()
|
||
|
grid.points(0.5, unit(2, "native"))
|
||
|
grid.line.to(0.5, unit(2,"native"))
|
||
|
@
|
||
|
\begin{center}
|
||
|
{
|
||
|
\includegraphics[width=5in, height=4in]{moveline-fig}
|
||
|
}
|
||
|
\end{center}
|
||
|
|
||
|
@
|
||
|
\end{document}
|
||
|
|
||
|
|
||
|
|