Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 49 lines (43 sloc) 1.917 kB
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
1 dotstackGrob <- function (
23568c2 @wch geom_dotplot: Change y range to total height of 1
wch authored
2 x = unit(0.5, "npc"), # x pos of the dotstack's origin
3 y = unit(0.5, "npc"), # y pos of the dotstack's origin
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
4 stackaxis = "y",
5 dotdia = unit(1, "npc"), # Dot diameter in the non-stack axis, should be in npc
6 stackposition = 0, # Position of each dot in the stack, relative to origin
7 stackratio = 1, # Stacking height of dots (.75 means 25% dot overlap)
1244716 @hadley Trim whitespace
authored
8 default.units = "npc", name = NULL, gp = gpar(), vp = NULL)
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
9 {
1244716 @hadley Trim whitespace
authored
10 if (!is.unit(x))
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
11 x <- unit(x, default.units)
1244716 @hadley Trim whitespace
authored
12 if (!is.unit(y))
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
13 y <- unit(y, default.units)
1244716 @hadley Trim whitespace
authored
14 if (!is.unit(dotdia))
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
15 dotdia <- unit(dotdia, default.units)
16 if (attr(dotdia,"unit") != "npc")
17 warning("Unit type of dotdia should be 'npc'")
18
19 grob(x = x, y = y, stackaxis = stackaxis, dotdia = dotdia,
20 stackposition = stackposition, stackratio = stackratio,
bee21f3 @wch Fix uppercase for dotstackGrob
wch authored
21 name = name, gp = gp, vp = vp, cl = "dotstackGrob")
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
22 }
23
3c63ff7 @hadley Convert from @S3method to @export
authored
24 #' @export
25 #' @method drawDetails dotstackGrob
bee21f3 @wch Fix uppercase for dotstackGrob
wch authored
26 drawDetails.dotstackGrob <- function(x, recording = TRUE) {
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
27
28 # Need absolute coordinates because when using npc coords with circleGrob,
29 # the radius is in the _smaller_ of the two axes. We need the radius
23568c2 @wch geom_dotplot: Change y range to total height of 1
wch authored
30 # to instead be defined in terms of the non-stack axis.
173094a @wch dotplot: add docs and clean up code
wch authored
31 xmm <- convertX(x$x, "mm", valueOnly = TRUE)
32 ymm <- convertY(x$y, "mm", valueOnly = TRUE)
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
33
34 if(x$stackaxis == "x") {
173094a @wch dotplot: add docs and clean up code
wch authored
35 dotdiamm <- convertY(x$dotdia, "mm", valueOnly = TRUE)
23568c2 @wch geom_dotplot: Change y range to total height of 1
wch authored
36 xpos <- xmm + dotdiamm * (x$stackposition * x$stackratio + (1 - x$stackratio) / 2)
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
37 ypos <- ymm
38 } else if(x$stackaxis == "y") {
173094a @wch dotplot: add docs and clean up code
wch authored
39 dotdiamm <- convertX(x$dotdia, "mm", valueOnly = TRUE)
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
40 xpos <- xmm
23568c2 @wch geom_dotplot: Change y range to total height of 1
wch authored
41 ypos <- ymm + dotdiamm * (x$stackposition * x$stackratio + (1 - x$stackratio) / 2)
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
42 }
43
44 grid.draw(
173094a @wch dotplot: add docs and clean up code
wch authored
45 circleGrob(x = xpos, y = ypos, r = dotdiamm / 2, default.units = "mm",
46 name = x$name, gp = x$gp, vp = x$vp),
5a5fefc @wch Change from dotclusterGrob to dotstackGrob.
wch authored
47 )
48 }
Something went wrong with that request. Please try again.