我试图在基本图形图中为每个颜色不同的颜色设置y轴值,但我无法弄清楚如何做到这一点。 类似的东西:
plot(1:5,col.ylabels= c("red","orange","yellow","green","blue"))
感谢您的帮助。
答案 0 :(得分:1)
您需要取消初始轴值并替换为自定义text
。
plot(1:5, col = c("red", "orange", "yellow", "green", "blue"), yaxt = 'n')
lablist <- as.vector(c(1:5))
text(par("usr")[1] - 0.4, 1:5 + 0.25,
labels = lablist, pos = 1, xpd = TRUE,
col = c("red","orange","yellow","green","blue"))
我通过引用?text
处的文档为https://stats.idre.ucla.edu/r/faq/how-can-i-change-the-angle-of-the-value-labels-on-my-axes/处的示例添加了颜色。