Sunday, 15 September 2013

r - How to use grid.gradientFill -



r - How to use grid.gradientFill -

i'm trying utilize function grid.gradientfill gridsvg package, unfortunately i'm not able see gradient in svg output.

i'm not sure if code right or browser not work (chrome: 35.0.1916.153 m), can please give advise?

here r code:

library(grid) library(gridsvg) lg <- lineargradient(col = c("black", "white", "black")) x <- c(0.2,0.2,0.35,0.5,0.65,0.8,0.8,0.65,0.5,0.35) y <- c(0.5,0.6,0.61,0.7,0.81,0.8,0.7,0.71,0.6,0.51) s <- c(0,0,-1,0,-1,0,0,-1,0,-1) grid.newpage() vp <- viewport(width=0.75, height=0.75) pushviewport(vp) grid.rect(gp=gpar(col="blue")) pushviewport(viewport(layout.pos.col=1, layout.pos.row=1)) grid.rect(x = unit(0.5, "npc"), y = unit(0.5, "npc"), width = unit(1, "npc"), height = unit(1, "npc"), = "centre", default.units = "npc", gp=gpar(col="green", fill = "blue"), draw = true, name = "tom") grid.xspline(x = x, y = y,shape=s, open=false, gp=gpar(col=na, fill="darkred"), name="spline") grid.gradientfill("spline", lg) grid.gradientfill("tom", lg) grid.export("c:/@temp/somekindofgradient.svg")

i'm interested in giving spline gradient ...

any hint appreciated :-)

so, found solution :-)

if want use

grid.gradientfill(object, ...)

the object, in question grid.xspline(...) object called "spline" not have have fill parameter, meaning ...

replacing

grid.xspline(x = x, y = y,shape=s, open=false, gp=gpar(col=na, fill="darkred"), name="spline")

with

grid.xspline(x = x, y = y,shape=s, open=false, gp=gpar(col=na), name="spline")

and there beautiful gradient :-)

r r-grid

No comments:

Post a Comment