File: base.R

package info (click to toggle)
r-cran-gridbase 0.4-7-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 340 kB
  • sloc: sh: 16; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 1,453 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

# Generate a list of viewports that correspond to the current base
# inner region, figure region, and plot region
baseViewports <- function() {
  omi <- par("omi")
  innervp <- viewport(x=unit(omi[2], "inches"),
                      y=unit(omi[1], "inches"),
                      width=unit(1, "npc") -
                        unit(omi[1], "inches") -
                        unit(omi[3], "inches"),
                      height=unit(1, "npc") -
                        unit(omi[2], "inches") -
                        unit(omi[4], "inches"),
                      just=c("left", "bottom"))
  fig <- par("fig")
  figurevp <- viewport(x=unit(fig[1], "npc"),
                       y=unit(fig[3], "npc"),
                       width=unit(fig[2] - fig[1], "npc"),
                       height=unit(fig[4] - fig[3], "npc"),
                       just=c("left", "bottom"))
  plt <- par("plt")
  usr <- par("usr")
  logscale <- FALSE
  if (par("xlog") || par("ylog")) {
    warning("viewport scales NOT set to user coordinates")
    logscales <- TRUE
  }
  plotvp <- viewport(x=unit(plt[1], "npc"),
                     y=unit(plt[3], "npc"),
                     width=unit(plt[2] - plt[1], "npc"),
                     height=unit(plt[4] - plt[3], "npc"),
                     just=c("left", "bottom"),
                     xscale=c(usr[1], usr[2]),
                     yscale=c(usr[3], usr[4]))
  list(inner=innervp, figure=figurevp, plot=plotvp)
}