Hi
Kexin Ji wrote:> 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"),
> space="Lab")(200)))
>
> I want a same one parallel to it to the right.
This should at least run for you ...
# Come back out of original viewport
popViewport()
# Push new viewport alongside
pushViewport(viewport(x = unit(0.648, "npc"), y=unit(0.386,
"npc"),
width=unit(.62 , "npc"), height=unit(0.006,
"npc"),
angle=137.2))
grid.rect(y=100:1/100, just="top",
gp=gpar(col=NA,
fill=colorRampPalette(c("lightgray",
"white"),
space="Lab")(200)))
popViewport()
... but that still might not look like what you want; you might want to
use just one viewport and draw each set of rectangles in half the height
of the viewport.
Paul
> I've tried something like:
>
> pushViewport(viewport(x = unit(c(0.638, 0.648), "npc"), y
> =unit(c(0.386, 0.386), "npc"), width=unit(c(.62, .62) ,
"npc"),
> height=unit(c(0.006, 0.006), "npc"), angle=137.2, layout
> =grid.layout(1,2)))
>
> grid.rect(y=100:1/100, just="top",
> gp=gpar(col=NA,
> fill=colorRampPalette(c("lightgray",
"white"),
> space="Lab")(200)))
>
> grid.rect(y=100:1/100, just="top",
> gp=gpar(col=NA,
> fill=colorRampPalette(c("lightgray",
"white"),
> space="Lab")(200)))
>
> Or
>
> vpList(pushViewport(viewport(x = 0.638, y = 0.386, 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)))
>
> But kept getting error messages.
>
> Would someone please give me some hint?
>
> Thank you very much!!
> Kexin
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/