2

如何在所有底部面板下显示轴?在此示例中,如果存在缺少正方形的网格,则不会显示轴。

library(lattice)
arr<- array(replicate(10, rnorm(10)), dim =c(10,10,10) )
dotplot(arr, type = "b", horizontal = F, col = "red",
    main =list( " Centrality", cex=1.5), xlab.top="",as.table=T,
    ylab =list( "Centralities", cex=1.3), 
    xlab = list("Proportion Cutpoints"), 
    scale=list(y=list(cex=1.2,  alternating =1), cex =1),
    auto.key=list(  points = F, border= "grey",
                      space = "top", lines = T, columns=4,height=10,
                      title = "Technologies"),
    par.settings = list(superpose.line = list(col = "red", lwd=2, lty=1:6 ),
                        layout.heights= list(xlab.key.padding = 1), 
                        layout.widths = list(key.ylab.padding = 1)),
    par.strip.text = list(cex=1.5))

缺少标签

4

1 回答 1

1

您必须修改负责绘制轴的函数。
简单的方法是强制指定面板的轴:

axis_filled <- function(side, ...) {
    if (side=="bottom" && panel.number() %in% c(7,8)) {
        axis.default(side = side, labels="yes", ticks="yes", ...)
    } else {
        axis.default(side = side, ...)
    }
}

dotplot(arr, type = "b", horizontal = F, col = "red",
    main =list( " Centrality", cex=1.5), xlab.top="",as.table=T, ylab =list( "Centralities", cex=1.3), xlab = list("Proportion Cutpoints"), 
    scale=list(y=list(cex=1.2,  alternating =1), cex =1),
    auto.key=list(points = FALSE, border= "grey", space = "top", lines = TRUE, columns=4,height=10, title = "Technologies"),
    par.settings = list(superpose.line = list(col = "red", lwd=2, lty=1:6 ),                            layout.heights= list(xlab.key.padding = 1), layout.widths = list(key.ylab.padding = 1)),
    par.strip.text = list(cex=1.5),
    axis=axis_filled
)

填写的标签

更通用的解决方案是检查面板是否已满。例如:

axis_filled <- function(side, ...) {
    force_axis <- if (side=="bottom") {
        panel.layout <- trellis.currentLayout("panel")
        # next to last row and nothing below:
        current.row() == nrow(panel.layout)-1 && panel.layout[current.row()+1,current.column()]==0
    } else FALSE
    if (force_axis) {
        axis.default(side = side, labels="yes", ticks="yes", ...)
    } else {
        axis.default(side = side, ...)
    }
}
于 2012-10-04T06:51:47.867 回答