标签: r plot axis-labels
f <- as.factor(sample( rep(c("a", "b", "c"), 3))) plot(1:9,f)
在y轴上给出值1.0..3.0。
如何在y轴上获得f(“a”,“b”和“c”)的值?
答案 0 :(得分:3)
f <- as.factor(sample( rep(c("a", "b", "c"), 3)))
R base
plot(1:9, f, yaxt = "n") axis(2, 1:3, levels(f))
<强>晶格强>
see fdetsch answer
<强> GGPLOT2 强>
library(ggplot2) qplot(seq_along(f), f)
答案 1 :(得分:1)
使用格子非常容易。
library(lattice) xyplot(f ~ 1:length(f))