Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could custumize the pairs function. If you look at the code, the axis are drawn within 2 nested for-loops (one for rows and one for colums):</p> <p>Here is a custimized pairs function, were I just edited the sides in localAxis() within these for-loops:</p> <pre><code>pairs2 &lt;- function (x, labels, panel = points, ..., lower.panel = panel, upper.panel = panel, diag.panel = NULL, text.panel = textPanel, label.pos = 0.5 + has.diag/3, cex.labels = NULL, font.labels = 1, row1attop = TRUE, gap = 1) { textPanel &lt;- function(x = 0.5, y = 0.5, txt, cex, font) text(x, y, txt, cex = cex, font = font) localAxis &lt;- function(side, x, y, xpd, bg, col = NULL, main, oma, ...) { if (side%%2 == 1) Axis(x, side = side, xpd = NA, ...) else Axis(y, side = side, xpd = NA, ...) } localPlot &lt;- function(..., main, oma, font.main, cex.main) plot(...) localLowerPanel &lt;- function(..., main, oma, font.main, cex.main) lower.panel(...) localUpperPanel &lt;- function(..., main, oma, font.main, cex.main) upper.panel(...) localDiagPanel &lt;- function(..., main, oma, font.main, cex.main) diag.panel(...) dots &lt;- list(...) nmdots &lt;- names(dots) if (!is.matrix(x)) { x &lt;- as.data.frame(x) for (i in seq_along(names(x))) { if (is.factor(x[[i]]) || is.logical(x[[i]])) x[[i]] &lt;- as.numeric(x[[i]]) if (!is.numeric(unclass(x[[i]]))) stop("non-numeric argument to 'pairs'") } } else if (!is.numeric(x)) stop("non-numeric argument to 'pairs'") panel &lt;- match.fun(panel) if ((has.lower &lt;- !is.null(lower.panel)) &amp;&amp; !missing(lower.panel)) lower.panel &lt;- match.fun(lower.panel) if ((has.upper &lt;- !is.null(upper.panel)) &amp;&amp; !missing(upper.panel)) upper.panel &lt;- match.fun(upper.panel) if ((has.diag &lt;- !is.null(diag.panel)) &amp;&amp; !missing(diag.panel)) diag.panel &lt;- match.fun(diag.panel) if (row1attop) { tmp &lt;- lower.panel lower.panel &lt;- upper.panel upper.panel &lt;- tmp tmp &lt;- has.lower has.lower &lt;- has.upper has.upper &lt;- tmp } nc &lt;- ncol(x) if (nc &lt; 2) stop("only one column in the argument to 'pairs'") has.labs &lt;- TRUE if (missing(labels)) { labels &lt;- colnames(x) if (is.null(labels)) labels &lt;- paste("var", 1L:nc) } else if (is.null(labels)) has.labs &lt;- FALSE oma &lt;- if ("oma" %in% nmdots) dots$oma else NULL main &lt;- if ("main" %in% nmdots) dots$main else NULL if (is.null(oma)) { oma &lt;- c(4, 4, 4, 4) if (!is.null(main)) oma[3L] &lt;- 6 } opar &lt;- par(mfrow = c(nc, nc), mar = rep.int(gap/2, 4), oma = oma) on.exit(par(opar)) dev.hold() on.exit(dev.flush(), add = TRUE) for (i in if (row1attop) 1L:nc else nc:1L) for (j in 1L:nc) { localPlot(x[, j], x[, i], xlab = "", ylab = "", axes = FALSE, type = "n", ...) if (i == j || (i &lt; j &amp;&amp; has.lower) || (i &gt; j &amp;&amp; has.upper)) { box() # edited here... # if (i == 1 &amp;&amp; (!(j%%2) || !has.upper || !has.lower)) # localAxis(1 + 2 * row1attop, x[, j], x[, i], # ...) # draw x-axis if (i == nc &amp; j != nc) localAxis(1, x[, j], x[, i], ...) # draw y-axis if (j == 1 &amp; i != 1) localAxis(2, x[, j], x[, i], ...) # if (j == nc &amp;&amp; (i%%2 || !has.upper || !has.lower)) # localAxis(4, x[, j], x[, i], ...) mfg &lt;- par("mfg") if (i == j) { if (has.diag) localDiagPanel(as.vector(x[, i]), ...) if (has.labs) { par(usr = c(0, 1, 0, 1)) if (is.null(cex.labels)) { l.wid &lt;- strwidth(labels, "user") cex.labels &lt;- max(0.8, min(2, 0.9/max(l.wid))) } text.panel(0.5, label.pos, labels[i], cex = cex.labels, font = font.labels) } } else if (i &lt; j) localLowerPanel(as.vector(x[, j]), as.vector(x[, i]), ...) else localUpperPanel(as.vector(x[, j]), as.vector(x[, i]), ...) if (any(par("mfg") != mfg)) stop("the 'panel' function made a new plot") } else par(new = FALSE) } if (!is.null(main)) { font.main &lt;- if ("font.main" %in% nmdots) dots$font.main else par("font.main") cex.main &lt;- if ("cex.main" %in% nmdots) dots$cex.main else par("cex.main") mtext(main, 3, 3, TRUE, 0.5, cex = cex.main, font = font.main) } invisible(NULL) } data(iris) pairs2(iris[1:4], main = "Anderson's Iris Data -- 3 species",pch = 21, bg = c("red", "green3", "blue")[unclass(iris$Species)]) </code></pre> <p><img src="https://i.stack.imgur.com/armTg.png" alt="enter image description here"></p> <p><strong>Edit</strong> Changed pairs2(), so that the axis appear only on the lower diagonal.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload