2

我想做一个像这样的简单图表:

ff<-data.frame(Freq=c(rep(10000,10),rep(100,15),rep(10,50),rep(1,100)))
plot(log(ff$Freq),type="l")

是添加 ax 变量的唯一选择吗?

require(ggplot2)
ff$Ord <- 1:nrow(ff)
ggplot(data=ff,aes(x=Ord,y=log(Freq))) + geom_line() 

提前致谢

4

1 回答 1

3

这是 geom_step() 的一种方法:

library(ggplot2)
library(scales)
ggplot(ff, aes(x = seq_along(Freq), y = log10(Freq))) + geom_step(size = 1) +
   labs(x = "Index", y = "Freq") +
   scale_y_continuous(labels = math_format(10^.x))
于 2013-01-16T05:32:25.800 回答