gpt4 book ai didi

R 带有 ggplot 的简单单变量图

转载 作者:行者123 更新时间:2023-12-04 05:15:25 24 4
gpt4 key购买 nike

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

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

是添加 x 变量的唯一选择吗?
require(ggplot2)
ff$Ord <- 1:nrow(ff)
ggplot(data=ff,aes(x=Ord,y=log(Freq))) + geom_line()

提前致谢

最佳答案

这是 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))

关于R 带有 ggplot 的简单单变量图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14346481/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com