簡體   English   中英

R繪圖因子,y軸上的值

[英]R plotting factor with values on y-axis

f <- as.factor(sample( rep(c("a", "b", "c"), 3)))

plot(1:9,f)

在y軸上給出值1.0..3.0。

如何在y軸上獲得f(“a”,“b”和“c”)的值?

f <- as.factor(sample( rep(c("a", "b", "c"), 3)))

R基地

plot(1:9, f, yaxt = "n")
axis(2, 1:3, levels(f))

格子

see fdetsch answer

GGPLOT2

library(ggplot2)
qplot(seq_along(f), f)

使用晶格非常容易。

library(lattice)
xyplot(f ~ 1:length(f))

xyplot

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM