search for: gpar

Displaying 20 results from an estimated 282 matches for "gpar".

Did you mean: gpa
2009 Dec 03
2
Passing arguments to gpar
Dear R-users, I would like to know how to pass arguments to gpar() without hard-coding them. I tried to store my arguments in a list and passed this list to gpar(), but it did find the way to do it properly. Any help would be appreciated. a<- list(fontisze=8,col=3) gpar(fontsize=8,col=3) gpar(a) gpar(unlist(a))
2005 Dec 08
1
grid graphics gpar(fill) argument and jpeg device
Hi everybody, I just notice a strange behaviour of gpar's fill argument when using non-postscript devices: The default of the argument is transparent (according to get.gpar("fill")). So as expected, the following code draws a nice red rectangle in the middle of my X11 or postscript device. pushViewport(viewport(width=0.5, height=0.5)) g...
2011 Nov 18
1
How to fill irregular polygons with patterns?
...ith patterns, Something like the function grid.pattern do, but my case is with irregular polygons. Whit this script I can get it, but I'm looking for an "elegant" solution.. library(grid) grid.polygon(x=c(0.2, 0.8, 0.6, 0.6, 0.8, 0.2), y=c(0.2, 0.2, 0.3, 0.5, 0.7,0.7), gp=gpar(fill="grey", alpha=0.9)) tmp=seq(0.225,0.7,0.075) for(i in 1:length(tmp)) { grid.abline(intercep=tmp[i], slope=0, units="npc", range=c(0.21,0.79), gp=gpar(lty=c("F8","2"), lwd=1.1)) } tmp2=seq(0.265,0.685,0.075) for(i in 1:length(tmp2)) { grid.abl...
2010 Aug 04
1
gpar fill and transparency on devices
Dear list, I'm puzzled by the graphical output in the following example, library(grid) foo <- function(){ grid.rect(gp=gpar(fill="black")) print(get.gpar()$fill) grid.rect(width=0.2,height=0.2) } png("test.png", bg = "transparent") foo() dev.off() png("test1.png", bg = "white") foo() dev.off() It seems that the default value of gpar()$fill is set according to the...
2005 Jan 19
1
Should NEVER happen; please bug.report() [mkCLOSXP] (PR#7535)
...bly not using the function right, but anyway, the program said: "please bug.report." > w_R.f1=function(PR,Pc) return (Pc*PR^3) > > w_R.f2=function(PR,Pc) return (Pc*PR) > > w_R.fc=c(w_R.f1,w_R.f2) > w_R.fc[2] [[1]] function(PR,Pc) return (Pc*PR) > > RSD(type=3, + gparP=gpar(col="red"), + gparD=gpar(fill=FALSE,col=FALSE), + gparL=gpar(col="red",lwd=2), + gparSL=gpar(col=grey(0.5),lwd=2), + gparS=gpar(fill=FALSE,col=FALSE), + gparSP=gpar(col=grey(0.7)), + w_R.f=w_R.fc[2] + ) Error in R2SDgraph(...) : couldn't find function "w_R.f"...
2009 Mar 21
1
Forestplot () box size question
...if (!cliplower) { ends <- "last" lims <- unit(c(LL, 1), c("native", "npc")) } grid.lines(x = lims, y = 0.5, arrow = arrow(ends = ends, length = unit(0.05, "inches")), gp = gpar(col = col$lines)) if (!clipbox) grid.rect(x = unit(OR, "native"), width = unit(size, "snpc"), height = unit(size, "snpc"), gp = gpar(fill = col$box, col = col$box)) } else {...
2008 Aug 17
1
Making use of names of viewports (grid)
...) 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 = "dashed", lwd = .1)) grid.text(cube.k, y = .9, gp = gpar(cex = .8)) popViewport() } ## label first viewport in bottom row pushViewport(viewport(layout = vps, name = "Cube5", layout.pos.row = 3, layout.pos.col = 1)...
2007 Sep 19
4
fontsize in mosaic plot lables
Hi List, I am trying unsucessfully to modify the fontsize of lables in mosaic: require(vcd) mosaic(Titanic, pop=FALSE, labeling_args=list(rot_labels=c(bottom=90,top=90), set_varnames = c(Sex = "Gender"), gp_text=gpar(fontsize=20))) #can't get it to resize text tab <- ifelse(Titanic < 6, NA, Titanic) # it works for labeling_cells labeling_cells(text = tab, margin = 0,gp_text=gpar(fontsize=20))(Titanic) What am I doing wrong? Thanx Herry
2007 Jul 24
1
How to add circular text for a graph with concentric circles
...as I have it now. Thank you very much, best regards, Suhas # Conurbano1a.R # R Program to generate circles, radii based on proportion of ALL STUDENTS # Prepared by Suhas, Tuesday, July 24, 2007 grid.circle(x=0.5, y=0.5, r=3*(.1268), default.units="npc", name=NULL, gp=gpar(fill="olivedrab1",col=NULL), draw=TRUE, vp=NULL) grid.circle(x=0.5, y=0.5, r=3*(0.095882), default.units="npc", name=NULL, gp=gpar(fill="cornflowerblue",col=NULL), draw=TRUE, vp=NULL) grid.circle(x=0.5, y=0.5, r=3*(0.077894), default.units="npc&q...
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
2006 Aug 01
1
R crashes using pdf() windows() or postscript()
...w32 status major 2 minor 3.1 year 2006 month 06 day 01 svn rev 38247 language R version.string Version 2.3.1 (2006-06-01) draw.rectangle <- function( label, figurename="figure", figurepath=getwd(), box.gpar=gpar(fill=rgb(red=51, green=51, blue=204, maxColorValue = 255), col=rgb(red=128, green=128, blue=128, maxColorValue = 255), lwd=2), text.gpar=gpar(col="white", fontface="bold", fontsize=14, cex=1, fontfamily="sans"), type...
2009 Sep 19
1
matrix operations on grobs and grid units
...ncol){ # colMax with a fake matrix of units matrix.indices <- matrix(seq_along(u), ncol=ncol) do.call(unit.c, lapply(seq(1, ncol), function(ii) { max(u[matrix.indices[, ii]]) })) } makeTableGrobs <- function(e, ncol, nrow, just = c("center", "center"), gpar.text = gpar(col="black", cex=1), gpar.fill = gpar(fill = "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 la...
2020 May 19
2
Graphic parameters with length zero in grid cause R to crash
Hi, I found in grid package, if the graphic parameters have zero length, R crashes. In the following code, I only tested `grid.rect()` and the `fill` parameter, but I think it should be similar as other grid graphic functions. In `gpar()` function, the graphic parameters are not allowed to have zero length, but we can make them with zero length by first generating a `gpar` object and then subsetting with zero length index, such as follows: ``` > library(grid) > gp = gpar(fill = 1) > grid.rect(gp = gp[integer(0)]) ``` A...
2001 Nov 27
1
What name-value pairs can be used in gpar()?
To use grid graphics with lattice, the help for gpar indicates that any number of named arguments can be specified but where do we find what names make any sense? I have ascertained that fontsize is given in points such as one would use in a postscript device argument and uses that same name. It's not as I'd have thought, something correspon...
2004 Nov 22
4
How to correct this
Hi there, I tried to add a few circles on an existing figure using the following codes grid.circle(x=0.5, y=0.5, r=0.1, draw=TRUE, gp=gpar(col=5)) grid.circle(x=0.5, y=0.5, r=0.3, draw=TRUE, gp=gpar(col=5)) grid.circle(x=0.5, y=0.5, r=0.5, draw=TRUE, gp=gpar(col=5)) points(0.5, 0.5, col = 5) # centre of the circle , but all circles moved away from the centre. Could we do any corrections to this? Thanks. Regards, Jin =...
2009 Jun 24
1
parallel rotated strips with color gradient
...uce 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"), space="Lab")(200))) I want a same one parallel to it to the right. I've tried something like: pushViewport(viewport(x = unit(c(0.638, 0.648), "n...
2008 Aug 08
2
gridBase and new.page() / grid.newpage()
...d. 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'))) par(plt = gridPLT(), new = TRUE) grid.rect(gp=gpar(fill="light...
2009 Jun 26
1
gradient fill of a grid.polygon
...;- 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 seems needed to overlap well height=gy, just="bottom") if(stripe){ if(ii%%2)# plotting only every other slice grid.draw(editGrob(g, gp=gpar(fill=cols[ii], col=cols[ii], alpha=alpha))) }else{ grid.draw(editGrob(g, gp=gpar(fill=cols[ii], col=cols[ii], alpha=alpha))) } } } g <- polygonGrob(x=c(0, 0.5, 1), y=c(0.5, 1, 0.5), gp=gpar(fill=NA, col="grey90")) g2 <- polygonGrob(x=c(0, 0.5, 1), y=c(0.5, 0, 0.5), gp=gpar(fil...
2012 Oct 09
2
plot.new() and grid functions in multipage pdfs
Hi, when using the grid package, I've come across this weird behaviour where a call to plot.new() will start a new page for a multi-page pdf, but then the margins will somehow behave strangely for all but the first page: here is some code: pdf("test.pdf"); plot.new(); grid.rect(gp = gpar(fill="blue")); plot.new(); grid.rect(gp = gpar(fill="blue")); dev.off() The first page is filled completely with a blue rectangle, but in the second page, the margins clip the rectangle. This is causing me considerable headache, as I rely on many grid functions for plotting. T...
2008 Aug 06
1
grid layout scaling viewport width based solely on height
...#39;snpc')) pushViewport(viewport(layout = lout2)) for(i in seq(0, 1, length.out = 10)) { pushViewport(viewport(y = i, width = unit(1, 'snpc'), height = unit(1, 'snpc'))) grid.rect(gp = gpar(col = 3)) popViewport() } popViewport() popViewport() popViewport() grid.newpage() lout3 <- grid.layout(nrow = 10, ncol = 11, respect = matrix(c(rep(0, 10 * 10), rep(0, 10 - 1), 1), nrow = 10) ) pushViewport(viewport(layout = lout3, w = 0.8, h = 0.8...