search for: textgrob

Displaying 20 results from an estimated 43 matches for "textgrob".

2008 Jan 12
2
Lattice equivalent of par(mfrow = )
Dear r-helpers, Does anyone have a straightforward example of putting together three unrelated (expect for a common y-axis) xyplot() figures in what would be in base graphics a par(mfrow = c(1, 3)) arrangement? _____________________________ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400 Charlottesville, VA 22904-4400 Parcels: Room 102
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"),
2012 Dec 12
2
long margin text below lattice plot - how to wrap lines?
...ice plot and need to add text into the bottom margin of the plotting area (below the bottom legend). This seems to work in principle using grid.arrange, yet the text to be added is rather long. As a consequence, it gets clipped: require(lattice) require(grid) myplot <- xyplot(1~1) mytext <- textGrob("This is such a very very long text that it goes on forever and therefore needs to be wrapped in order for someone to be able to read it properly.") grid.arrange(myplot, sub=mytext) Is there any way to wrap the lines of the text or some other of workaround to this problem? I've trie...
2005 Oct 03
1
Grid: constructing a gTree with grobs that use named viewports from a vpTree
...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 the appropriate viewports. I h...
2009 Sep 09
1
Xyplot, multi line title via main, all lines left justified
...5)) xyplot(y ~ t | as.factor(group), data = data.ex, main = list("Put figure caption here xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx want this line left justified" )) I must be mis-interpreting the help description for main under xyplot, and the descriptions of just, hjust, and vjust in textGrob, since manipulation of these arguments do not seem to produce the desired result of having the second line of text left-justified. Any help much appreciated. David
2010 Apr 28
1
Multiple cex sizes in main for xyplot?
Folks: I would like to write two lines of text in two different font sizes (or faces or ...) as the title ("main") of a trellis plot. The following code does it, but not well: xyplot((0:1)~(0:1), main = textGrob(lab=c("Some Text","Some More Text"),y=c(.95,.8), gp=gpar(cex=c(1.2,1.0))) ) There is too much space between the title text and the plot. I assume that can be fixed by fooling with padding settings in lattice.options(), but my question is: Is there a better, simpler way to d...
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)) ## not...
2007 Jun 18
1
Second y-axis in xyplot (lattice) where y1 and y2 have different ranges
...;") axis(4, at=pretty(range(dat$Samples))) mtext("Number of Samples", 4, 3) xyplot(Stuff + Samples ~ Year | Grp, data=dat, layout = c(1, 1), panel = panel.superpose.2, ylab = "Stuff", legend = list(right = list(fun = grid::textGrob("Samples", rot = 90))), type = c('l', 'l')) dat2 <- data.frame(Year = rep(1751:2000,2), Stuff = rep(rnorm(250),2), Samples = rep(floor(seq(5,30,length.out=250)+ rnorm(250,5)),2),...
2005 Jun 02
0
Thanks! (was panel.axis() & grid/lattice settings)
...t; > > >>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, > grobWidth(textG...
2010 Mar 29
1
xyplot second y-xis and legend
...rid.pars=list(fontfamily="serif",cex=1), layout.widths=list(right.padding=8), simpleTheme(pch=c(1,2,3,4),lty=c(1,2),lwd=2,cex=1.5)), auto.key=list(draw=TRUE,points=TRUE,lines=TRUE, text=LETTERS[1:4]), legend = list(right=list(fun = grid::textGrob("AB", x=4,rot = 90)))) -- View this message in context: http://n4.nabble.com/xyplot-second-y-xis-and-legend-tp1695032p1695032.html Sent from the R help mailing list archive at Nabble.com.
2010 Mar 19
2
lattice grob
Dear list, I'm trying to arrange various grid objects on a page using a frameGrob. It works fine with basic grobs (textGrob, gTree, etc.), and also with ggplot2 objects using the ggplotGrob() function. I am however stuck with lattice. As far as I understand, lattice produces a list of class trellis, which is eventually displayed using the plot.trellis method. I am not sure if/how one can convert this list into a high-le...
2009 Sep 20
1
packGrob and dynamic resizing
Dear all, I'm trying to follow an old document 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 fra...
2009 Sep 19
1
matrix operations on grobs and grid units
...quot;grey95", col="white", lwd=1.5)) { n <- length(e) # number of labels stopifnot(!n%%2) # only rectangular layouts if(missing(ncol) & missing(nrow)){ nm <- n2mfrow(n) # pretty default layout ncol = nm[1] nrow = nm[2] } makeOneLabel <- function(label.ind){ textGrob(label=e[label.ind], gp=gpar.text, name=paste("cells-label-",label.ind, sep="")) } lg <- lapply(seq_along(e), makeOneLabel) # list of grobs wg <- lapply(lg, grobWidth) # list of grob widths hg <- lapply(lg, grobHeight) # list of grob heights widths.all <- do.call(un...
2005 Feb 18
1
Examples of multiple key grobs
The xyplot help page gives quite a lot of information how to use key and indicates that legend needs to be used if multiple keys are needed. However, it gives only a brief description of what the grob needs to contain to do multiple keys. I've only used the occasional grid function in panel functions, so I don't have much of a sense of how grobs are constructed. I've been unable to
2009 Oct 23
1
Distance between axis and label adjusted automatically?
...provide a "safety margin", but it looks stupid when there is too much space between label and axis. I tried to use the relative positioning mechanism of frames, roughly like this: fb <- packGrob(fg,yaxisGrob(vp="dataRegion"),side="left") fg <- packGrob(fg,textGrob("y axis label",rot=90),side="left") But it appears that the true size of the axis is not respected; numbers on the axis and the label still may overlap. Can anyone provide a simple example how to do this right? I would favor a solution using the 'grid' package. Than...
2009 Sep 27
0
puzzle with drawDetails for a class derived from a gTree
...for some reason - the resulting gTree doesn't appear to contain children, they seem "hidden" from the user in the drawDetails method Any advice will be much appreciated! Best regards, Baptiste ## two function that create the text grobs make.test.right <- function(lab, col) { textGrob(lab, gp=gpar(col=col), name="right", vp="rightvp") } make.test.left <- function(lab, col) { textGrob(lab, gp=gpar(col=col), name="left", vp="leftvp") } grid.test <- function(right="right text", left="left text", col = "red&q...
2007 May 26
1
lattice: aligning independent graphs
I find myself wanting to plot three graphs side by side 'as if' they were panels -- that is, with the same y-axis limits, no space between the graphs, and precise vertical alignment of the plot areas. However, I don't want strip titles; I want each graph to have its own x-axis label, on the bottom of the plot. The best way I have so far found to do this is to fake up a data frame that
2011 Apr 10
3
Adding margin text to lattice graphics
Colleagues I am learning lattice graphics (R 2.12.2; OS X). Several days ago, I inquired about adding margin text to lattice graphics. Jim Price offered a useful reply, suggesting that I add: page = function(page) grid.text('words', x = 0.5, y = 0.01) to my call to the function. The entire function that he suggested was; xyplot(1 ~ 1, par.settings = list(layout.heights =
2013 Jan 15
5
Duda gráficos - paper="a4"
Buenos días: A ver si alguien me puede iluminar, porque ya he sobrepasado los límites de mi paciencia y de mi imaginación con este asunto: Dado un gráfico creado con un plot (y funciones auxiliares como polygon, etc.) y una tabla creada debajo de ese gráfico (creada con addtable2plot), y dados unos text situados a modo de título encima del plot y otros encima de la tabla, ¿por qué cuando trato
2005 Nov 12
1
Updating in attempt to rotate ylab
What am I doing wrong? (please cc me when replying) yy <- 1:10 xx <- yy*2 xYplot(yy~xx,ylab="") #this plots as it should text(.4,5,expression(paste(log, frac(p(b),p(a)) ))) Error in text.default(0.4, 13, expression(paste(log, frac(p(b), p (a))))) : plot.new has not been called yet This is the case even when I write: xxyy <- xYplot(yy~xx,ylab="") xxyy <-