更改基 R 中轴标签的颜色

问题描述 投票:0回答:1

我想更改 Base R 中轴标签的颜色。想出如何更改轴线颜色,但轴上似乎没有开关来更改标签颜色。 下面的最小示例......如何使每个轴上的所有数字标签变为灰色(4.5 到 8.0 水平轴和 1 到 7 垂直轴)和轴标签(iris$Sepal.Length 和 iris$Petal.Length)?

plot(iris$Sepal.Length,iris$Petal.Length, 
bty = "n", axes = FALSE)
axis(1, col = "grey")
axis(2, col = "grey", las = 1)
r
1个回答
0
投票

您可以使用 par() 函数中的 col.axis 参数更改轴标签的颜色,如下所示:

plot(iris$Sepal.Length, iris$Petal.Length, bty = "n", axes = FALSE)

# Set the axis line color
axis(1, col = "grey")
axis(2, col = "grey", las = 1)

# Set the axis label color
par(col.axis = "grey")
© www.soinside.com 2019 - 2024. All rights reserved.