Displaying 19 results from an estimated 19 matches for "rectgrob".
2011 Mar 04
1
Units and dimensions in grid object
Dear R-users,
As far as I understand, when one defines the width of a rectGrob call using
a 'npc' unit, the width of the object is proportional to the width of the
current viewport. Is there a way to refer to the height (or width) of the
viewport when defining the width (or height) of the rectGrob object?
Thanks
Sebastien
[[alternative HTML version deleted]]
2011 Nov 10
1
grid.pack and grid.frame bewilder me
Hello R friends,
I get quite confused in using the grid graphic function grid.pack( )
and grid.frame ( ). Here is a simple example:
library(grid)
grid.frame(name="frame1")
grid.pack("frame1",rectGrob(width=unit(0.5,"npc"),
height=unit(0.5,"npc"), gp=gpar(col="red")))
what I expect is a rectangle with half the default device's
dimensions,but it returns a rectangle like 1/4 of the device.why?
In addition wonder what the rectGrob is referred to if there are x.y...
2011 Feb 15
1
gList and gTree methods of grid::grobX
Dear all,
In an attempt to draw fill patterns in grid graphics, I have
encountered a behavior of grobX that I cannot understand from the
documentation. Consider this,
library(grid)
## gTree
g1 <- gTree(children=gList(
rectGrob(0.5,0.5, width=unit(0.8,"npc"),
height=unit(2,"cm")),
circleGrob(r=0.3)), vp=viewport(0.5,0.5))
## gList
g1 <- gList(rectGrob(0.5,0.5, width=unit(0.8,"npc"),
height=unit(2,"cm")),
circleG...
2011 Apr 26
2
grid stringHeight
Dear all,
I'm puzzled by the behavior of stringHeight in the grid package.
Consider the following test,
library(grid)
test <- function(lab="dog", ...){
g1 <- textGrob(lab)
g2 <- rectGrob(height=grobHeight(g1), width=grobWidth(g1))
gg <- gTree(children=gList(g1,g2), ...)
print(c("height:", convertUnit(stringHeight(lab), "mm", "y")))
grid.draw(gg)
}
grid.newpage()
test()
test(expression(dog), vp=viewport(x=0.6))
## notice how the dog's tai...
2005 Oct 03
2
grob questions
If I run the following example from:
http://www.stat.auckland.ac.nz/~paul/grid/doc/grobs.pdf
> grid.newpage()
> pushViewport(viewport(w = 0.5, h = 0.5))
> myplot <- gTree(name = "myplot", children = gList(rectGrob(name = "box",
+ gp = gpar(col = "grey")), xaxisGrob(name = "xaxis")))
> grid.draw(myplot)
> grid.edit("myplot::xaxis", at = 1:10/11)
> grid.edit("myplot::xaxis::labels", label = round(1:10/11, 2))
> grid.edit("myplot::xaxis::labels&...
2010 Oct 01
2
strange interaction between rasterImage and Grid graphics
...d a chance to test another
platform. Consider this,
plot(1,1,t="n")
rasterImage(matrix(1),1,1,1,1)
library(grid)
grid.rect(gp=gpar(fill="grey"))
The grid.rect covers the full device window as expected. However, when
I resize the window ever so slightly (interactive device) the rectGrob
is suddenly clipped to the previous plot window. I cannot understand
this behavior, and it doesn't happen if one removes the rasterImage()
call, so I suspect something iffy is going on with the display list or
something.
The only device I've tried is quartz(), x11() crashed with rasterImag...
2005 Oct 03
1
Grid: constructing a gTree with grobs that use named viewports from a vpTree
...here they should go.
library(grid)
vp <- vpTree(
viewport(layout=grid.layout(2,2), name="layout"),
children=vpList(
viewport(layout.pos.col = 1, layout.pos.row=1, name="tl"),
viewport(layout.pos.col = 2, layout.pos.row=2, name="br")
)
)
grobs <- gList(
rectGrob(vp="tl"),
textGrob("Top left", vp="tl"),
textGrob("Bottom right", vp="br")
)
I can draw the grobs using the following code:
grid.newpage()
pushViewport(vp)
upViewport(1)
grid.draw(grobs)
But I want a grob that represents those grobs drawn in t...
2009 Sep 20
1
packGrob and dynamic resizing
...ent to use Grid frames,
Creating Tables of Text Using grid
Paul Murrell
July 9, 2003
As a minimal example, I wrote this,
gf <- grid.frame(layout = grid.layout(1, 1), draw = TRUE)
label1 <- textGrob("test", x = 0, just = "left", name="test")
gf=placeGrob(gf, rectGrob(), row = 1, col = 1)
gf=packGrob(gf, label1, row = 1, col = 1)
grid.draw(gf)
grid.edit("test", label = "longer text", grep=T)
I'm a bit lost here, as I was expecting the frame to be automatically
adjusted to fit the new text.
Can anyone point me in the right direction?
B...
2009 Jan 19
1
Floating point excepting when cbind()ing a matrix of grobs (or environments) with a 0-column matrix
library(grid)
e <- rectGrob()
# OR:
# e <- environment()
a <- matrix(list(e), ncol = 1, nrow = 2)
b <- matrix(ncol = 0, nrow = 2)
cbind(a, b)
cbind(a, b)
This reliably crashes R for me.
I realise this is a rather esoteric error condition, but it crops up
for me when creating matrices of grobs to be turned into a...
2009 May 21
1
size of point symbols
...#39;t understand the rationale in the absolute sizes of the point
symbols, and I couldn't find it documented. The example below uses
Grid to check the size of the symbols against a square of 10mm x 10mm.
> checkOneSymbol <- function(pch=0){
> gTree(children=gList(
> rectGrob(0.5, 0.5, width=unit(10, "mm"), height=unit(10,
> "mm"),
> gp=gpar(lty=2, fill=NA, col=alpha("black", 0.5))),
> pointsGrob(0.5, 0.5, size=unit(10, "mm"),pch=pch,
> gp=gpar(col=alpha("red", 0.5)))
> ))...
2009 May 21
1
size of point symbols
...#39;t understand the rationale in the absolute sizes of the point
symbols, and I couldn't find it documented. The example below uses
Grid to check the size of the symbols against a square of 10mm x 10mm.
> checkOneSymbol <- function(pch=0){
> gTree(children=gList(
> rectGrob(0.5, 0.5, width=unit(10, "mm"), height=unit(10,
> "mm"),
> gp=gpar(lty=2, fill=NA, col=alpha("black", 0.5))),
> pointsGrob(0.5, 0.5, size=unit(10, "mm"),pch=pch,
> gp=gpar(col=alpha("red", 0.5)))
> ))...
2009 Sep 19
1
matrix operations on grobs and grid units
...ol, just=just,
widths = widths,
heights = heights) )
label.ind <- 1 # index running for the vector of labels
for (ii in seq(1, ncol, 1)) {
for (jj in seq(1, nrow, 1)) {
gcells = placeGrob(gcells, rectGrob(gp=gpar.fill,
name=paste("cells-fill-r",ii, "-c",jj,sep="")),
row=jj, col=ii)
text.grob.ij = textGrob(label=e[label.ind],
gp=gpar.text, name=paste("cells-label-r",ii,
"-c",jj,sep=""...
2005 Apr 14
2
Legend in xyplot two columns
Dear R-Help
I have some trouble to set the legend in a xyplot into two rows.
The code below gives me the legend in the layout I am looking for, I
just rather have it in two rows.
library(lattice)
schluessel <- list(
points=list( col="red", pch=19, cex=0.5 ),
text=list(lab="John"),
lines=list(col="blue"),
2010 Aug 11
2
help to polish plot in ggplot2
Hi,
I wanted to generate a plot which is almost like the plot generated by the
following codes.
category <- paste("Geographical Category", 1:10)
grp1 <- rnorm(10, mean=10, sd=10)
grp2 <- rnorm(10, mean=20, sd=10)
grp3 <- rnorm(10, mean=15, sd=10)
grp4 <- rnorm(10, mean=12, sd=10)
mydat <- data.frame(category,grp1,grp2,grp3,grp4)
dat.m <- melt(mydat)
p <-
2012 Apr 13
0
Reference Class import() behaviour
...)
}))
b.gen <- setRefClass("classB", contains = "classA")
library(grid)
my.vps <- vpTree(viewport(name = "parent"),
vpList(viewport(name = "child")))
my.gtree <- gTree(name = "tree",
children = gList(rectGrob(vp = "parent"),
textGrob("test", vp = "child")))
a <- a.gen$new(vps = my.vps, gt = my.gtree, nums = 11:20)
b <- b.gen$new()
a$view()
b$view()
# Everything works as expected so far...
# Now lets try importing the fields from a...
2006 Jul 29
3
placing rectangle behind plot
I am trying to create a lattice plot and would like to later, i.e. after
the plot is drawn, add a grey rectangle behind a portion of it.
The following works except that the rectrangle is on top of and
obscures a portion of the chart. I also tried adding col = "transparent"
to the gpar list but that did not help -- I am on windows and
perhaps the windows device does not support
2009 Dec 01
6
raster support in graphics devices
Hi
This is for developers of extension packages that provide extra
*graphics devices* for R.
In the *development* version of R, support has been added to the
graphics engine for sending raster images (bitmaps) to a graphics
device. This consists mainly of two new device functions: dev_Raster()
and dev_Cap().
The R_GE_version constant (in GraphicsEngine.h) has been bumped up to 6
as a
2004 Oct 04
7
R 2.0.0 is released
...9;s class. This allows packages with namespaces to have
private (non-exported) classes.
o Changes to package 'grid':
- Calculation of number of circles to draw in circleGrob now
looks at length of y and r as well as length of x.
- Calculation of number of rectangles to draw in rectGrob now
looks at length of y, w, and h as well as length of x.
- All primitives (rectangles, lines, text, ...) now handle
non-finite values (NA, Inf, -Inf, NaN) for locations and
sizes.
Non-finite values for locations, sizes, and scales of
viewports result in error messages.
There...
2004 Oct 04
7
R 2.0.0 is released
...9;s class. This allows packages with namespaces to have
private (non-exported) classes.
o Changes to package 'grid':
- Calculation of number of circles to draw in circleGrob now
looks at length of y and r as well as length of x.
- Calculation of number of rectangles to draw in rectGrob now
looks at length of y, w, and h as well as length of x.
- All primitives (rectangles, lines, text, ...) now handle
non-finite values (NA, Inf, -Inf, NaN) for locations and
sizes.
Non-finite values for locations, sizes, and scales of
viewports result in error messages.
There...