【问题标题】:Missing some inside text in the basic plot plotted from corres.fnc data从 corres.fnc 数据绘制的基本图中缺少一些内部文本
【发布时间】:2019-02-24 08:43:58
【问题描述】:

我有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”,只是“比较”出现在情节上。如何扩大绘图区域以呈现所有文本?

【问题讨论】:

  • 尝试传递 xlimylim 参数,例如plot(md.ca, xlim = c(-0.7, 0.7)).
  • 我试过了,但没有帮助。
  • 你能把你的question reproducible设为吗?
  • 能否请您单击链接的“数据”字以复制数据表并将数据导入为 tags_ms
  • 要添加到@AkselA 的评论中,您的示例应该是独立的,并且不应回复外部资源。很抱歉没有事先说明清楚。

标签: r plot


【解决方案1】:

您可以通过设置stretch=2 或类似的设置来适应所有内容,但它会对称地扩展窗口限制。

plot(md.ca, stretch=2)

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

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))

你可以询问函数的作者是否可以修改它。
他的姓名和联系方式是?corres.fnc

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-14
    • 2019-09-19
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多