The R Project SVN R

Rev

Rev 51723 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 51723 Rev 52414
Line 1... Line 1...
1
 
1
 
2
R version 2.12.0 Under development (unstable) (2010-04-14 r51721)
2
R version 2.12.0 Under development (unstable) (2010-06-30 r52412)
3
Copyright (C) 2010 The R Foundation for Statistical Computing
3
Copyright (C) 2010 The R Foundation for Statistical Computing
4
ISBN 3-900051-07-0
4
ISBN 3-900051-07-0
5
 
5
 
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
7
You are welcome to redistribute it under certain conditions.
7
You are welcome to redistribute it under certain conditions.
Line 930... Line 930...
930
> grid.segments(0, 0, grobX("ref", 0), grobY("ref", 0))
930
> grid.segments(0, 0, grobX("ref", 0), grobY("ref", 0))
931
> 
931
> 
932
> 
932
> 
933
> 
933
> 
934
> cleanEx()
934
> cleanEx()
-
 
935
> nameEx("grid.path")
-
 
936
> ### * grid.path
-
 
937
> 
-
 
938
> flush(stderr()); flush(stdout())
-
 
939
> 
-
 
940
> ### Name: grid.path
-
 
941
> ### Title: Draw a Path
-
 
942
> ### Aliases: grid.path pathGrob
-
 
943
> ### Keywords: dplot
-
 
944
> 
-
 
945
> ### ** Examples
-
 
946
> 
-
 
947
> pathSample <- function(x, y, rule, gp=gpar()) {
-
 
948
+     if (is.na(rule))
-
 
949
+         grid.path(x, y, id=rep(1:2, each=4), gp=gp)
-
 
950
+     else 
-
 
951
+         grid.path(x, y, id=rep(1:2, each=4), rule=rule, gp=gp)
-
 
952
+     if (!is.na(rule))
-
 
953
+         grid.text(paste("Rule:", rule), y=0, just="bottom")
-
 
954
+ }
-
 
955
> 
-
 
956
> pathTriplet <- function(x, y, title) {
-
 
957
+     pushViewport(viewport(height=0.9, layout=grid.layout(1, 3),
-
 
958
+                           gp=gpar(cex=.7)))
-
 
959
+     grid.rect(y=1, height=unit(1, "char"), just="top",
-
 
960
+               gp=gpar(col=NA, fill="grey"))
-
 
961
+     grid.text(title, y=1, just="top")
-
 
962
+     pushViewport(viewport(layout.pos.col=1))
-
 
963
+     pathSample(x, y, rule="winding",
-
 
964
+                gp=gpar(fill="grey"))
-
 
965
+     popViewport()
-
 
966
+     pushViewport(viewport(layout.pos.col=2))
-
 
967
+     pathSample(x, y, rule="evenodd",
-
 
968
+                gp=gpar(fill="grey"))
-
 
969
+     popViewport()
-
 
970
+     pushViewport(viewport(layout.pos.col=3))
-
 
971
+     pathSample(x, y, rule=NA)
-
 
972
+     popViewport()
-
 
973
+     popViewport()
-
 
974
+ }
-
 
975
> 
-
 
976
> pathTest <- function() {
-
 
977
+     grid.newpage()
-
 
978
+     pushViewport(viewport(layout=grid.layout(5, 1)))
-
 
979
+     pushViewport(viewport(layout.pos.row=1))
-
 
980
+     pathTriplet(x=c(.1, .1, .9, .9, .2, .2, .8, .8),
-
 
981
+                 y=c(.1, .9, .9, .1, .2, .8, .8, .2),
-
 
982
+                 title="Nested rectangles, both clockwise")
-
 
983
+     popViewport()
-
 
984
+     pushViewport(viewport(layout.pos.row=2))
-
 
985
+     pathTriplet(x=c(.1, .1, .9, .9, .2, .8, .8, .2),
-
 
986
+                 y=c(.1, .9, .9, .1, .2, .2, .8, .8),
-
 
987
+                 title="Nested rectangles, outer clockwise, inner anti-clockwise")
-
 
988
+     popViewport()
-
 
989
+     pushViewport(viewport(layout.pos.row=3))
-
 
990
+     pathTriplet(x=c(.1, .1, .4, .4, .6, .9, .9, .6),
-
 
991
+                 y=c(.1, .4, .4, .1, .6, .6, .9, .9),
-
 
992
+                 title="Disjoint rectangles")
-
 
993
+     popViewport()
-
 
994
+     pushViewport(viewport(layout.pos.row=4))
-
 
995
+     pathTriplet(x=c(.1, .1, .6, .6, .4, .4, .9, .9),
-
 
996
+                 y=c(.1, .6, .6, .1, .4, .9, .9, .4),
-
 
997
+                 title="Overlapping rectangles, both clockwise")
-
 
998
+     popViewport()
-
 
999
+     pushViewport(viewport(layout.pos.row=5))
-
 
1000
+     pathTriplet(x=c(.1, .1, .6, .6, .4, .9, .9, .4),
-
 
1001
+                 y=c(.1, .6, .6, .1, .4, .4, .9, .9),
-
 
1002
+                 title="Overlapping rectangles, one clockwise, other anti-clockwise")
-
 
1003
+     popViewport()
-
 
1004
+     popViewport()
-
 
1005
+ }
-
 
1006
> 
-
 
1007
> pathTest()
-
 
1008
> 
-
 
1009
> 
-
 
1010
> 
-
 
1011
> cleanEx()
935
> nameEx("grid.plot.and.legend")
1012
> nameEx("grid.plot.and.legend")
936
> ### * grid.plot.and.legend
1013
> ### * grid.plot.and.legend
937
> 
1014
> 
938
> flush(stderr()); flush(stdout())
1015
> flush(stderr()); flush(stdout())
939
> 
1016
>