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 に答える