search for: pushviewport

Displaying 20 results from an estimated 175 matches for "pushviewport".

2008 Aug 06
1
grid layout scaling viewport width based solely on height
...Hopefully, my explanation makes my goal clear. Also note, the real application is a function that will have arbitrary numbers of side plots. Thanks Peter require(grid) grid.newpage() lout1 <- grid.layout(nrow = 1, ncol = 2, widths = unit(c(1, 1/10), c('null', 'snpc')) ) pushViewport(viewport(layout = lout1, w = 0.8, h = 0.8)) pushViewport(viewport(layout.pos.col = 1)) grid.rect() popViewport() pushViewport(viewport(layout.pos.col = 2)) lout2 <- grid.layout(nrow = 10, ncol = 1, heights = unit(1, 'snpc')) pushViewport(v...
2011 Apr 28
2
gridBase Base Plot Positioning
...as my best effort. Can someone explain how to keep the column of boxplots on the same page as the rectangles (even though I've tried new = TRUE) ? Also, would it be hard / possible to match up the middle of each boxplot to the middle of each rectangle ? pdf("tmp.pdf", h = 6, w = 10) pushViewport(plotViewport(c(5, 5, 4, 2))) pushViewport(viewport(layout = grid.layout(4, 6))) for(i in 1:5) { for(i2 in 1:4) { pushViewport(viewport(layout.pos.row = i2, layout.pos.col = i)) grid.rect() popViewport() } } pushViewport(viewport(layout.pos.col = 6)) plot.new() pa...
2009 Jul 21
2
animated grid graphics
I need to make a fairly complex animated graphic and decided to use grid for it. A very simple example of what I need: ##============================================================================== library(grid) grid.newpage() pushViewport(plotViewport()) pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100)))) grid.xaxis() grid.yaxis() rectNames <- paste("r", 1:100, sep = "") for (i in 1:100) { grid.rect(x = unit(sample(0:100, 1), "native"),...
2005 Jul 28
2
lattice/ grid.layout/ multiple graphs per page
Background: OS: Linux Mandrake 10.1 release: R 2.0.0 editor: GNU Emacs 21.3.2 front-end: ESS 5.2.3 --------------------------------- Colleagues I have a set of lattice plots, and want to plot 4 of them on the page. I am having trouble with the layout. grid.newpage() pushViewport(viewport(layout = grid.layout(2,2))) pushviewport(viewport(layout.pos.col = 1, layout.pos.row = 1)) working trellis graph code here pushviewport(viewport(layout.pos.col = 1, layout.pos.row = 2)) working trellis graph code here pushviewport(viewport(layout.pos.col = 2, layout.pos.row = 1)) working t...
2008 Mar 04
1
grid.layout?
...<- 5 variates <- LETTERS[1:N] grid.newpage() plot.square <- 2 * length(variates)# cm text.wid <- 3 # cm vp <- grid.layout(nrow = 1, ncol = 2, widths = c(text.wid, plot.square), heights = plot.square, default.units = "cm") pushViewport(viewport(layout = vp, layout.pos.row = 1, layout.pos.col = 2)) ## vpp <- grid.layout(nrow = length(variates), ncol = length(variates), widths = 2, heights = 2, default.units = "cm") pushViewpo...
2007 Oct 24
1
Rotated viewports in Grid
...rary(grid) x<-rnorm(20) y<-rnorm(20) graph.layout<-grid.layout(nrow=2,ncol=2,widths=unit.c(unit(2,"null"),unit(1,"null")),heights=unit.c(unit(1,"null"),unit(2,"null"))) graph.view<-viewport(layout=graph.layout,name="root") grid.newpage() pushViewport(gap.view) pushViewport(viewport(layout.pos.row=2,layout.pos.col=1)) print(xyplot(x~y),newpage=FALSE) popViewport() pushViewport(viewport(layout.pos.row=1,layout.pos.col=1)) print(densityplot(x),newpage=FALSE) popViewport() pushViewport(viewport(layout.pos.row=2,layout.pos.col=2,angle=270)) print(de...
2007 Oct 19
1
Using grid graphics (hexbin) in pairs() plot problem
...se documentation contains a sample which has a normal ("base") plot with two columns, and some code to use grid commands to paint rectangles. library(grid) library(gridBase) 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) if I continue with a second plot (a...
2004 Sep 07
1
gridBase and heatmap
...fferent viewports. I can get the placement correct, but I keep 'losing' the previous plot. Any suggestions? Here is some quick example code trying to put a heatmap into the left viewport and then put a second one into the upper right. Thanks in advance for insight.... Sean > pushViewport(viewport(layout = grid.layout(1, 3, widths = unit(rep(1,3), c("null", "cm", "null"))))) viewport[GRID.VP.177] > pushViewport(viewport(layout.pos.col=1)) viewport[GRID.VP.178] > par(omi=gridOMI(),new=T) > my.heatmap(eb$coefficients[(clsum[,1]>1) & (...
2011 Oct 31
1
Help combining cell labelling and multiple mosaic plots
...rom the tables). When I take out the pop=FALSE commands in the mosaic commands and comment out the two lines labelling the cells, then the plots are laid out exactly as I'd like: side-by-side. But I do require the cell labelling and the pop=FALSE arguments. I suspect I need to add in a call to pushViewport or an upViewport command, but I'm not sure. Any advice is welcome. library(vcd) library(grid) .test<-as.table(matrix(c(1, 2, 3, 4, 5, 6), nrow=3, ncol=2, byrow=TRUE)) .test<-prop.table(.test, 1) .test1<-as.table(matrix(c(1, 2, 3, 4), nrow=2, ncol=2, byrow=TRUE))...
2008 Aug 17
1
Making use of names of viewports (grid)
...--------------------- require(grid) wide <- 15 vps <- grid.layout(nrow = 3, ncol = 4, widths = unit(rep(1, 4), rep("null", 4)), heights = unit(c(99, 1, 99), c("mm", "null", "mm"))) pushViewport(viewport(layout = vps)) for(k in 1:4){# label 4 viewports in top row cube.k <- ppaste("Cube", k) pushViewport(viewport(layout = vps, name = cube.k, layout.pos.row = 1, layout.pos.col = k)) grid.rect(gp = gpar(lty = &quot...
2008 Jun 11
1
Problem when combining dotplot() and textplot() using grid
...ing package gplots) of the data.frame next to the dotplot. Example code: library(lattice) library(grid) library(gplots) xx <- data.frame(f=factor(rep(1:5, each=5)), gr= rep(c("gr1", "gr2", "gr3", "gr4", "gr5"), 5), val=rnorm(25)) grid.newpage() pushViewport(viewport(layout = grid.layout(1, 2))) pushViewport(viewport(layout.pos.col=1, layout.pos.row=1)) p <- dotplot(f ~ val, groups=gr, xx, cex=1.7, pch=20) print(p, newpage=FALSE) popViewport(1) pushViewport(viewport(layout.pos.col=2, layout.pos.row=1)) textplot(xx, show.rownames=FALSE)...
2005 May 31
2
Problem going back to a viewport with gridBase
...d add arbitrary additional line or point plots to them so the solution needs to be sufficiently general that I can so generalize it. Thanks. library(gridBase) opar <- par(no.readonly = TRUE) grid.newpage() # two columns, one row unit. <- unit(c(1,1), c("null","null")) pushViewport(viewport(layout = grid.layout(1, 2, widths = unit.))) # draw green graph in first column (viewport A) pushViewport(viewport(layout.pos.col = 1, name = "A")) par(fig = gridFIG()); par(new = TRUE) plot(1:10, col = "green", pch = 20) upViewport(1) # draw purple graph in second co...
2005 May 31
2
Problem going back to a viewport with gridBase
...d add arbitrary additional line or point plots to them so the solution needs to be sufficiently general that I can so generalize it. Thanks. library(gridBase) opar <- par(no.readonly = TRUE) grid.newpage() # two columns, one row unit. <- unit(c(1,1), c("null","null")) pushViewport(viewport(layout = grid.layout(1, 2, widths = unit.))) # draw green graph in first column (viewport A) pushViewport(viewport(layout.pos.col = 1, name = "A")) par(fig = gridFIG()); par(new = TRUE) plot(1:10, col = "green", pch = 20) upViewport(1) # draw purple graph in second co...
2004 Jun 28
1
text length in grid
...e either very small or very large, so I would like to label each by fitting its text to the size of the region in question. Ideally, I could have nice, big text labeling the big regions and tiny type in the small regions. Let me try to illustrate my scenario. Imagine that my plot looks like this: pushViewport(viewport(layout = grid.layout(5, 2, c(9,1), 1:5))) for (i in 1:5) { pushViewport(viewport(layout.pos.row = i, layout.pos.col = 1)) pushViewport(viewport(x = 0, width = i/5, height = .8, just = "left")) grid.rect(gp = gpar(fill = rainbow(5)[i])) grid.yaxis(main = F) grid.text(&qu...
2008 Aug 08
2
gridBase and new.page() / grid.newpage()
...R Graphics book and package vignette but didn't see this particular issue addressed. Thanks in advance, Peter myplot <- function() { grid.newpage() plot.new() n <- 10 datalayout <- grid.layout(ncol = 2, width = unit(c(1, 1/n), c('null', 'null'))) pushViewport(viewport(width = .8, height = .8, layout = datalayout)) grid.rect(gp=gpar(col="grey")) for(i in 1:n) { pushViewport(viewport( y = i/n - 0.5 / n, x = 1, height = unit(1/n, 'npc'), width = unit(1/n, 'npc'))) pa...
2008 Dec 05
1
Trouble with gridBase and inset plots
...t;Residence time for") text(1.3,1.21e8,cex=1.2,"a 6.5m long transfer tube") arrows(1.1, 7.7e7, time[21], 7.7e7, length = 0.,lwd=2) arrows( time[21], 7.7e7, time[21], tot_num_150[21]/1e6, length = 0.15,lwd=2) par( mar = c(0.,0., 0., 0.) ) #1st inset vp <- baseViewports() pushViewport(vp$inner,vp$figure,vp$plot) pushViewport(viewport(x=-0.0,y=1.04,width=.4,height=.4,just=c(0,1))) par(fig=gridPLT(),new=F) #grid.rect(gp=gpar(lwd=0,col="red")) plot(D_mean,data_150[1, ]/log_factor*log(10)/1e6,"l", pch=1,col="black", lwd=2,xlab="...
2008 Sep 25
1
grid.newpage()
...ts(bplot,target$target/xi[nrow(xi),],pch=20) text(bplot,target$target/xi[nrow(xi),],paste(target$target,"ha"),adj=c(-0.3, 0.5),cex=0.70,srt=90) But it fails when I try to put it into a grid with something like this: grid.newpage() par(cex.axis=0.85,cex.lab=0.80,mai=c(1.3,1,0.5,0),las=3) pushViewport(viewport(layout=grid.layout(1,2))) pushViewport(viewport(layout.pos.row=1,layout.pos.col=1)) print( bplot<-barplot(bar.values,width=0.5,ylab="% Area held",,names.arg=cf.names) abline(h=0.3,lty=3,col="red")) abline(h=0.1,lty=3,col="blue") points(bplot,target$target/x...
2009 Mar 31
1
viewport bug in 2.8.0?: Error: Cannot pop the top-level viewport (grid and graphics output mixed?)
...ror: Cannot pop the top-level viewport (grid and graphics output mixed?) Have reduced something much more complex in my code to a simple test case. I run the following and then resize the window: X = seq (1,10) Y = X^2 opar <- par(no.readonly=TRUE, mar = c(2.5, 3.1, 1, 2)) grid.newpage() pushViewport (viewport(x=0,y=0,width=1,height=1,just=c(0,0), name='base')) pushViewport (viewport(x=0,y=0.5,width=1,height=0.5,just=c(0,0))) par (fig=gridFIG()) # plot in top half of page plot (X,Y,col='black',xlab="",main='',cex.axis=.7) # get toplevel view seekViewport('...
2007 Jun 28
1
Changing graphics height when using grid and lattice
Hi, I have recently been playing with the grid package in an attempt to create some pages containing multiple lattice plots on the same page. However, when I specify a grid layout with different widths, such as: pushViewport(viewport(layout = grid.layout(1, 2, unit(c(2, 1), "null")))) the individual graphs do not end up as the same height - which is a feature I would prefer to have. A complete example is as follows: ### Start of example library(lattice) library(Hmisc) library(grid) # Incidence data tes...
2009 Jun 24
1
parallel rotated strips with color gradient
Hi, I want to produce two parallel rotated strips with color gradient. So far, the sample strip is something produced by this: pushViewport(viewport(x = unit(0.638, "npc"), y =unit(0.386, "npc"), width=.62, height=0.006, angle=137.2)) grid.rect(y=100:1/100, just="top", gp=gpar(col=NA, fill=colorRampPalette(c("lightgray", "white"),...