search for: grobwidth

Displaying 20 results from an estimated 23 matches for "grobwidth".

2007 Feb 12
1
Width of a plotting point (in inches) in grid package
...dth (as tried below), but this results in an object with a size of 0inches (changing cex has no effect). Does anyone have a better approach? Of course, it would be dependent upon the graphics parameters and viewport... Thanks, Randy > library(grid) > pushViewport(viewport()) > convertX(grobWidth(pointsGrob(1, 1)), 'inches') [1] 0inches # I think we're measuring the size of the point here... # changing cex has no effect. > convertX(grobWidth(pointsGrob(1, 1, gp = gpar(cex = 3))), 'inches') [1] 0inches # If I add a second point, the size should increase... # how big...
2005 Jun 02
0
Thanks! (was panel.axis() & grid/lattice settings)
...; > > > > >>convertX(unit(1, "strwidth", data = "foo"), "inches", TRUE) > > > > [1] 0.2344092 > > > > I think this would depend on the gpars() in effect, in > particular fontsize. > > > Yep. There's also grobWidth(textGrob("foo")), which gives > you not just > the size of a string, but the size of a text graphical object. The > difference is that a text graphical object can include > information about > where it will be drawn, in what font, and so on. For example, > grobWi...
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 tail is being cut off, where ## expression...
2004 Nov 08
3
location of key in panels of trellis plot
Hi, I want to insert a key into each panel of a trellis plot, which I can do with a custom panel function that calles draw.key. The problem arises because I want the top right hand corner of the key to start in the top right hand corner of the panel. If you run my code below, you can see that the key appears in the center of each panel. This is because the default viewport in draw.key is the
2009 Sep 19
1
matrix operations on grobs and grid units
...ist, As a minimal test of a more complex grid layout, I'm trying to find a clean and efficient way to arrange text grobs in a rectangular layout. The labels may be expressions, or text with a fontsize different of the default, which means that the cell sizes should probably be calculated using grobWidth() and grobHeight() as opposed to simpler stringWidth() and stringHeight(). (Correct?). The input of this function is a vector of labels, which are arranged into a matrix layout. Below is my current version, followed by a few questions. e = expression(alpha,"testing very large width", ha...
2007 Mar 25
1
controlling panel.width and panel.height in viewports
...t to get rid of the space (margins) around the longest axis for each variety of levelplot. So I tried to capture the viewport height and width and print the levelplot within a region which reflects the aspect ratio of the plot. I run into an error message as below: width.vp <- convertWidth(grobWidth(grid.rect()), 'cm') height.vp <- convertWidth(grobHeight(grid.rect()), 'cm') width.vp;height.vp # this works if(asp.ratio.1 < 1) {height.vp <- unit(as.numeric(height.vp)*asp.ratio.1, "cm")} if(asp.ratio.1 > 1) {width.vp <- unit(as.numeric(width.vp)/asp.ra...
2009 Mar 21
1
Forestplot () box size question
...= x, just = just, gp = gpar(fontface = if (is.summary[i]) "bold" else "plain", col = rep(col$text, length = nr)[i])) } } colgap <- unit(3, "mm") colwidths <- unit.c(max(unit(rep(1, sum(widthcolumn)), "grobwidth", labels[[1]][widthcolumn])), colgap) if (nc > 1) { for (i in 2:nc) colwidths <- unit.c(colwidths, max(unit(rep(1, sum(widthcolumn)), "grobwidth", labels[[i]][widthcolumn])), colgap) } colwidths <- unit.c(colwidths,...
2009 Jun 26
1
gradient fill of a grid.polygon
...,"npc") + gravity.y) } gradient.polygon <- function(g, n=100, cols=colorRampPalette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3"))(n), alpha=0.5, stripe=FALSE, angle=0){ vp = viewport(angle = angle) g = rotate.polygon(g, - angle) gx <- grobWidth(g) gy <- grobHeight(g) dx <- unit(convertX(gx, "npc", valueOnly = TRUE)/(n-1), "npc") # width of the stripes startx <- min(g$x) starty <- min(g$y) for(ii in seq(1, n)){ grid.clip(x= startx + (ii-1) * dx , y=starty, width= 1.0*dx, # fudge factor of 1.2...
2001 Sep 21
2
new versions of grid and lattice
...on of viewports, not the bug!). 2. Added grid.line.to() and grid.move.to(). These allow drawing BETWEEN different coordinate systems. See example in inst/doc/demo3.ps. 3. Added some more demonstrations to the doc directory. 4. Added more test code to the tests directory. 5. Added "grobwidth" and "grobheight" units. See the document grid/inst/doc/advanced/parentchild.ps 6. Added more detailed documentation to grid/inst/doc/advanced. This stuff is not necessarily very friendly for the reader, but may be useful if you're tearing your hair out wondering why...
2001 Sep 21
2
new versions of grid and lattice
...on of viewports, not the bug!). 2. Added grid.line.to() and grid.move.to(). These allow drawing BETWEEN different coordinate systems. See example in inst/doc/demo3.ps. 3. Added some more demonstrations to the doc directory. 4. Added more test code to the tests directory. 5. Added "grobwidth" and "grobheight" units. See the document grid/inst/doc/advanced/parentchild.ps 6. Added more detailed documentation to grid/inst/doc/advanced. This stuff is not necessarily very friendly for the reader, but may be useful if you're tearing your hair out wondering why...
2003 Dec 09
1
Key for custom lattice panel function
Hi all, I've created a custom lattice panel function for levelplot - instead of representing z by colour, it plot circles with radius proportional to z (in the style of the map plots of Jacques Bertin). I'm happy to email an example graph to anyone interested. The problem is now to create a key for the plot. This is difficult because all of the other lattice plots convey
2011 Mar 04
2
Creating a .png with just an expression() in it
Hey, I'm trying to create an image file with the results of a regression analysis. In TeX, the line would be something like: $ size = 0.34 + 4.3 var_1 $ Can I create a plot window with just this line in it? I tried playing around with plot.new() or dev.new(), but didn't really find something that worked. Thanks in advance, Alex -- alexx at alexx-fett:~$ vi .emacs
2011 Jan 31
0
Forest Plot Text
..._pval, forest_int) plot1<- forestplot(forest_text_table, forest_mean, forest_lower, forest_upper, digits=2,graphwidth = unit(2,"inches"), zero=1, clip = c(0.1, 2.50), title(main="Forest Plot")) #### I get the error message: "Error in unit(rep(1, sum(widthcolumn)), "grobwidth", labels[[1]][widthcolumn]) : 'x' and 'units' must have length > 0". Does anyone know how to fix this? S ________________________________ PHRI DISCLAIMER This information is directed in confidence solely to the person named above and may not otherwise be distribut...
2003 Apr 27
2
bug and proposed fix in print.trellis 1.7.0 (PR#2859)
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---1678264062-154654637-1051422990=:2626055 Content-Type: TEXT/PLAIN; charset=US-ASCII ---1678264062-154654637-1051422990=:2626055 Content-Type: TEXT/PLAIN; charset=US-ASCII;
2009 May 08
1
centering axis labels in lattice
Hello, I'm attempting to alter the location of text in my axis labels in lattice plots and have been unsuccessful so far. For example, the y-axis labels are always right-justified, but I would like them to be horizontally centered. Here's an example: library(lattice); # create fake dataset to plot to.plot <- data.frame( x = 1:5, y = c("1\nAAA", "2\nBBB",
2008 Oct 17
1
Using key.opts in Ecdf/labcurve (Hmisc package)
I'm presumably missing something very obvious, but how does one use the key.opts argument in labcurve (via Ecdf)? In this example, I want the key to be big and have a blue background, but it isn't and doesn't. ch <- rnorm(1000, 200, 40) sex <- factor(sample(c('female','male'), 1000, TRUE)) Ecdf(~ch, group=sex, label.curves=list(keys=c("f",
2005 Dec 07
0
organizing plot drawing routines; creating complex expressions
...key <- draw.key(list(background="white",border=TRUE,text=list(lab=levels(arg$data$e xpected.hierarchyTo)),lines=list(col=arg$col,pch=arg$pch,lty=arg$lty,lwd=arg $lwd))) vp<-viewport(x=0.9,y=grobHeight(key)+unit(0.07,"npc"),just=c("right","top"), width=grobWidth(key),height=grobHeight(key)) pushViewport(vp) grid.draw(key) As you can see each routine is a sequence of commands required to draw a single plot. Each routine is separated in the text file by comments. If I wanted all these plots drawn I could source the file, but oft...
2012 Sep 24
1
Adding textbox to multiple panels in lattice
Dear R-users, I am trying to add some text in a textbox to all panels in the following example file. Using the panel-function, I can add a white rectangle with panel.rect but then I have to fit in the text into the box by hand and it will not automatically be centered. Does anyone know how to add the text centered with a white box around it automatically? Is there something like panel.textbox for
2004 Apr 12
1
R 1.9.0 is release
...quot;name" slot. The grob name is used to uniquely identify a "drawn" grob (i.e., a grob on the display list). + grid.edit() and grid.pack() now take a grob name as the first argument instead of a grob. (Actually, they take a gPath - see below) + the "grobwidth" and "grobheight" units take either a grob OR a grob name (actually a gPath - see below). Only in the latter case will the unit be updated if the grob "pointed to" is modified. In addition, the following features are now possible with grobs: + grobs...
2004 Apr 12
1
R 1.9.0 is release
...quot;name" slot. The grob name is used to uniquely identify a "drawn" grob (i.e., a grob on the display list). + grid.edit() and grid.pack() now take a grob name as the first argument instead of a grob. (Actually, they take a gPath - see below) + the "grobwidth" and "grobheight" units take either a grob OR a grob name (actually a gPath - see below). Only in the latter case will the unit be updated if the grob "pointed to" is modified. In addition, the following features are now possible with grobs: + grobs...