如何删除 R 中的 levelplot 刻度边框?
How to remove levelplot tick border in R?
levelplot 函数在方框的所有边上都带有刻度线来渲染热图。我想保留 x 和 y 轴上的刻度线,但删除顶部和右侧的刻度线。
如何删除框周围的右边框和上边框?
#fake data
data(mtcars)
cars.matrix <- as.matrix(mtcars[c(2:8)])
cars.corr <- cor(cars.matrix)
library('lattice')
levelplot(cars.corr, xlab="car stuff",ylab="Car Stuff", main="car stuff")
您可以将参数 scales
传递给 levelplot
,它在 ?xyplot
中使用,您可以在其中找到描述:
scales
: Generally a list determining how the x- and y-axes (tick marks and labels) are drawn.
tck
Usually a numeric scalar controlling the length of tick marks. Can also be a vector of length 2, to control the length of left/bottom and right/top tick marks separately.
#fake data
data(mtcars)
cars.matrix <- as.matrix(mtcars[c(2:8)])
cars.corr <- cor(cars.matrix)
library('lattice')
levelplot(cars.corr, xlab="car stuff",ylab="Car Stuff", main="car stuff",
scales = list(tck = c(1,0)))
levelplot 函数在方框的所有边上都带有刻度线来渲染热图。我想保留 x 和 y 轴上的刻度线,但删除顶部和右侧的刻度线。
如何删除框周围的右边框和上边框?
#fake data
data(mtcars)
cars.matrix <- as.matrix(mtcars[c(2:8)])
cars.corr <- cor(cars.matrix)
library('lattice')
levelplot(cars.corr, xlab="car stuff",ylab="Car Stuff", main="car stuff")
您可以将参数 scales
传递给 levelplot
,它在 ?xyplot
中使用,您可以在其中找到描述:
scales
: Generally a list determining how the x- and y-axes (tick marks and labels) are drawn.
tck
Usually a numeric scalar controlling the length of tick marks. Can also be a vector of length 2, to control the length of left/bottom and right/top tick marks separately.
#fake data
data(mtcars)
cars.matrix <- as.matrix(mtcars[c(2:8)])
cars.corr <- cor(cars.matrix)
library('lattice')
levelplot(cars.corr, xlab="car stuff",ylab="Car Stuff", main="car stuff",
scales = list(tck = c(1,0)))