在这里,我得到了示例(how to set different x&y label in levelplot?),但是我想在两个轴上进行更多调整:
library(lattice)
library(RColorBrewer)
m <- matrix(c(0,1,1,2,0,2,1,1,0),6,6)
B= c('a','b','c','d','e','f','g', 'a','b','c','d','e','f','g')
XY.labels=B
cols <- colorRampPalette(brewer.pal(6, "Spectral"))
print(levelplot(m, scales = list(labels = XY.labels), col.regions = cols,
xlab='X Label', ylab='Y Label'))
在这里不要紧,
B= c('a','b','c','d','e','f','g', 'a','b','c','d','e','f','g')
OR
B= c('a','b','c','d','e','f','g')
所以我想更改两个轴的标签,例如:
B= c('a','b','c','d','e','f','g', 'h','i','j','k','l','m','n)
答案 0 :(得分:1)
我希望这是您想要的:
library(lattice)
library(RColorBrewer)
m <- matrix(c(0,1,1,2,0,2,1,1,0),6,6)
cols <- colorRampPalette(brewer.pal(6, "Spectral"))
levelplot(m,
scales=list(
x=list(at=1:6,labels=c("A","B","C","D","E","F")),
y=list(at=1:6,labels=c("G","H","I","J","K","L"))
),
col.regions = cols,
xlab='X Label', ylab='Y Label')
您需要为每个轴添加一个列表。然后像以前一样分配标签。使用附加的“ at”,您可以解决从0开始标记的问题。