从corres.fnc数据绘制的基本图中缺少一些内部文本

时间:2019-02-24 08:43:58

标签: r plot

我有data: 并希望对该数据进行对应分析。

md <- structure(list(Interpret_ALdc=c(11.522, 19.834, 8.122,
28.901, 20.778, 7.745, 9.634, 3.589, 8.311),
Compare_ALdc=c(10.005, 7.504, 16.008, 12.506, 12.506, 6.003,
8.004, 1.501, 1.501), Account_ALdc=c(10.503, 22.756, 9.502,
24.506, 15.754, 7.752, 6.252, 7.002, 8.252),
Interpret_MErd=c(21.536, 19.383, 1.436, 16.511, 22.254, 14.358,
27.997, 5.743, 7.897), Compare_MErd=c(18.282, 1.828, 13.711,
1.828, 6.399, 5.484, 5.484, 1.828, 2.742), Account_MErd=c(24.687,
13.167, 4.937, 9.217, 7.571, 18.433, 11.521, 16.458, 2.633)),
row.names=c("VBZ", "VM", "VVD", "VVI", "CST", "JJR", "VVZ",
"II21", "PPH1"), class="data.frame")

library(languageR)

md.ca <- corres.fnc(md)
plot(md.ca)

但是情节上缺少一些右侧的文本。图上仅显示“比较”,而不是“ Compare_MErd”。如何扩展绘图区域以显示所有文本?

1 个答案:

答案 0 :(得分:1)

您可以通过设置stretch=2或类似方法来容纳所有内容,但是它将对称地扩展窗口范围。

plot(md.ca, stretch=2)

enter image description here

修改plot.corres()的代码以允许进行xlim / ylim的调整非常简单。 F.ex:

plot.corres <- function (x, main = "", addcol = TRUE, extreme = 0, rcex = 1, 
    rcol = 1, rlabels = "", stretch, ccex = 1, ccol = 2, 
    clabels = "", xlim, ylim, ...) 
{
    if (!is(x, "corres")) 
        stop("argument should be a correspondence object")
    dat = x@data$origOut
    xlimit = range(dat$rproj[, 1])
    ylimit = range(dat$rproj[, 2])
    if (!missing(xlim)) {
        xlimit <- xlim
    }
    if (!missing(ylim)) {
        ylimit <- ylim
    }
    if (!missing(stretch)) {
        xlimit = xlimit * stretch
        ylimit = ylimit * stretch
    } 
    plot(dat$rproj[, 1], dat$rproj[, 2], type = "n", xlim = xlimit, 
        ylim = ylimit, xlab = paste("Factor 1  (", round(x@data$eigenrates[1]/10, 
            1), " %)", sep = ""), ylab = paste("Factor 2  (", 
            round(x@data$eigenrates[2]/10, 1), " %)", sep = ""), ...)
    lines(c(max(dat$rproj[, 1]), min(dat$rproj[, 1])), c(0, 0))
    lines(c(0, 0), c(max(dat$rpro[, 2]), min(dat$rproj[, 2])))
    if (!(main == "")) 
        mtext(main, 3, 1)
    if (length(rcol) == 1) 
        rcol = rep(1, nrow(dat$rproj))
    if (length(rlabels) == 1) 
        rlabels = rownames(x@data$input)
    text(dat$rproj[, 1], dat$rproj[, 2], rlabels, cex = rcex, 
        col = rcol)
    if (addcol) {
        if (length(clabels) == 1) 
            clabels = colnames(x@data$input)
        if (extreme > 0) {
            x = data.frame(dat$cproj[, 1:2])
            extremes = apply(x, 2, quantile, c(extreme, 1 - extreme))
            Accept = as.factor((x[, 2] < extremes[1, 2] | x[, 
                2] > extremes[2, 2]) | (x[, 1] < extremes[1, 
                1] | x[, 1] > extremes[2, 1]))
            text(x[Accept == TRUE, 1], x[Accept == TRUE, 2], 
                clabels[Accept == TRUE], font = 2, cex = ccex, 
                col = ccol)
        }
        else {
            text(dat$cproj[, 1], dat$cproj[, 2], clabels, font = 2, 
                cex = ccex, col = ccol)
        }
    }
}

plot(md.ca, xlim=c(-0.6, 1))

enter image description here

您可以问函数的作者是否可以修改它。
他的姓名和联系信息在?corres.fnc