[R] How to fill in a region with different patterns?

baptiste auguie baptiste.auguie at googlemail.com
Thu Feb 25 22:15:56 CET 2010


Hi,

If you are curious you might like to try a highly experimental Grid
function I wrote some time ago,

library(grid)
source("http://gridextra.googlecode.com/svn/trunk/R/patternGrob.r")

grid.newpage()
grid.pattern(x=seq(1/6, 5/6, length=6), width=unit(1/8,"npc"),
height=unit(0.5,"npc"),
             motif.width=unit(10, "mm"),  pattern=c(1:6),
orientation=45, motif.alpha=0.5,
             motif.cex=c(1, 0.5), motif.col=1:2, motif.fill=NA,
             gp=gpar(fill="blue", lwd=2, alpha=0.5),  clip=T)

If you really insist on using shading patterns despite Greg's sound
advice, it might give you some inspiration.

HTH,

baptiste


On 25 February 2010 04:34, St.Jeff Shang <mathshang at yahoo.com> wrote:
> Hi to all,
>
>
>
> Here is a question which I cannot solve. Appreciate so much for any suggestions!
>
>
>
> I have a squared region which is irregularly divided into many rectangular patches.
>
> Each patch is associated with a value, and two patches possibly share a common value.
>
> I hope to fill in each patch a pattern according to its value. For
> instance, if a patch has value 1, then I fill in that patch with
> pattern A; if it has value 2, then fill in it with pattern B,...
>
>
>
> The pattern is something like a rectangular region with certain colored
> lines in it. For instance, pattern A may be a white rectangular region
> filled in by two thick black lines;
>
> pattern B may be a white rectagular region filled in by 10 thick black lines,...
>
>
>
> Is this available in matlab? I have serached "polygnon" in matlab user guide and found a
>
> "fill function" may work, however, there is still a long way to finally complete it.
>
>
>
> Many thanks again!
>
> Jeff
>
>
>
>        [[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.
>



-- 
____________________

Baptiste Auguié

Departamento de Química Física,
Universidade de Vigo,
Campus Universitario, 36310, Vigo, Spain

tel: +34 9868 18617
http://webs.uvigo.es/coloides



More information about the R-help mailing list