如何在R中调整/控制树形图中的比例(使用"投资组合"库)?

NJ.*_*NJ. 5 portfolio r treemap

我正在使用R和'portfolio'库来构建树形图.比例默认为'-1000到1000'.

例如,我需要它为'0到1000'.我知道map.market()有一个'scale'参数,但我无法弄清楚要传递给它的内容.

Jam*_*mes 3

零附近的对称颜色映射被硬编码为map.market

legend.ncols <- 51
l.x <- (0:(legend.ncols - 1))/(legend.ncols)
l.y <- unit(0.25, "npc")
l.cols <- color.ramp.rgb(seq(-1, 1, by = 2/(legend.ncols - 
    1)))
if (is.null(scale)) {
    l.end <- max(abs(data$color.orig))
}
else {
    l.end <- scale
}
Run Code Online (Sandbox Code Playgroud)

和,

top.list <- gList(textGrob(label = main, y = unit(0.7, "npc"), 
    just = c("center", "center"), gp = gpar(cex = 2)), segmentsGrob(x0 = seq(0, 
    1, by = 0.25), y0 = unit(0.25, "npc"), x1 = seq(0, 1, 
    by = 0.25), y1 = unit(0.2, "npc")), rectGrob(x = l.x, 
    y = l.y, width = 1/legend.ncols, height = unit(1, "lines"), 
    just = c("left", "bottom"), gp = gpar(col = NA, fill = l.cols), 
    default.units = "npc"), textGrob(label = format(l.end * 
    seq(-1, 1, by = 0.5), trim = TRUE), x = seq(0, 1, by = 0.25), 
    y = 0.1, default.units = "npc", just = c("center", "center"), 
    gp = gpar(col = "black", cex = 0.8, fontface = "bold")))
Run Code Online (Sandbox Code Playgroud)

注意语句的存在seq(-1,1,...)。该scale参数仅影响绝对大小。