本文介绍了如何在水平图中设置不同的x& y标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用levelplot绘制矩阵.我需要更改x和y标签.当我使用以下代码时,plot看起来不错.但是x和y标签从133到139,而不是133..139 133 ... 139.谁能帮我解决这个问题?(而不是我要绘制的巨大矩阵,我将给出一个样本矩阵)
I am using levelplot to plot a matrix. I need to change x and y labels. When I use the following piece of code, plot looks nice. However x and y labels are from 133 to 139 as opposed to 133..139 133...139. Can anyone help me fix it?(instead of huge matrix i am plotting, I ll give a sample matrix)
library(lattice)
library(RColorBrewer)
m <- matrix(c(0,1,1,2,0,2,1,1,0),6,6)
b <- c(seq(133,139),seq(133,139))
xy.labels <- b
cols <- colorRampPalette(brewer.pal(6, "Spectral"))
print(levelplot(m, scales = list(labels = xy.labels), col.regions = cols))
推荐答案
我认为您可以简单地使用xlab
和ylab
选项.
I think you can simply use the xlab
and ylab
options.
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')
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'))
这篇关于如何在水平图中设置不同的x& y标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!