如何在莱迪思封装中的水平图的顶部X轴上添加标签 [英] How to Add Labels to Top X-Axis of Levelplot in Lattice Package
问题描述
因此,我正在使用与此类似的levelplot进行类似相关矩阵的绘图(摘自:
So I'm making correlation-matrix-like plots using levelplot similar to this (taken from: Plot correlation matrix into a graph):
library(lattice)
#Build the horizontal and vertical axis information
hor <- c("214", "215", "216", "224", "211", "212", "213", "223", "226", "225")
ver <- paste("DM1-", hor, sep="")
#Build the fake correlation matrix
nrowcol <- length(ver)
cor <- matrix(runif(nrowcol*nrowcol, min=0.4), nrow=nrowcol, ncol=nrowcol, dimnames = list(hor, ver))
for (i in 1:nrowcol) cor[i,i] = 1
#Build the plot
rgb.palette <- colorRampPalette(c("blue", "yellow"), space = "rgb")
levelplot(cor, main="stage 12-14 array correlation matrix", xlab="", ylab="", col.regions=rgb.palette(120), cuts=100, at=seq(0,1,0.01))
我想为每个顶部(第二个)x轴刻度线添加标签.有人知道如何做到这一点吗?
I would like to add labels to each of the top (second) x-axis ticks. Does anyone know how to accomplish this?
谢谢
开
推荐答案
您可以通过在levelplot
如果您查找levelplot
的帮助,请参考xyplot
(及其他),以获取某些信息.在xyplot
帮助页面中,您可以找到scales
的说明以及alternating
.交替控制刻度标签的位置,可以采用4个值:
If you look up the help for levelplot
, for some information, you are referred to xyplot
(and others). It is in the xyplot
help page, you find a description of scales
and therein alternating
. Alternating controls the location of the tick labels and can take 4 values:
-
0
(无), -
1
(底部/左侧), -
2
(顶部/右侧), -
3
(两者).
0
(none),1
(bottom/left),2
(top/right),3
(both).
以下是对levelplot的调用,可让您在各个方面进行报价:
Here is the call to levelplot that gives you ticks at all sides:
levelplot(cor, main="stage 12-14 array correlation matrix", xlab="", ylab="", col.regions=rgb.palette(120), cuts=100, at=seq(0,1,0.01), scales=list(alternating=3))
这篇关于如何在莱迪思封装中的水平图的顶部X轴上添加标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!