本文介绍了绘图意味着用ggplot绘制散点图上的线图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有这个简单的数据框,为每个因子(CT)保存三个重复值(值)。我想将它绘制成geom_point,而不是以geom_line的形式表示。 gene 值 df df 所以,我可以制作散点图。 b $ g 我如何获得代表每个因子平均值的geom_line。我已经尝试了stat_summary: $ g $ p $ g $ p $ ggplot(df,aes(x = CT,y = value))+ geom_point()+ stat_summary(aes(y = value,group = CT),fun.y = mean,color =red,geom =line) 但它不起作用。 geom_path:每组仅包含一个观察值,您是否需要调整组审美? 但每组有三个观察值,哪些是错误的? Ps。 $ c $ = 1: $ pre $ g $ pggplot(df,aes(x = CT,y = value))+ geom_point()+ stat_summary(aes(y = value,group = 1),fun.y = mean,color =red,geom =line,group = 1) p> I have this simple data frame holding three replicates (value) for each factor (CT). I would like to plot it as geom_point and than the means of the point as geom_line.gene <- c("Ckap5","Ckap5","Ckap5","Ckap5","Ckap5","Ckap5","Ckap5","Ckap5","Ckap5","Ckap5","Ckap5","Ckap5","Ckap5","Ckap5","Ckap5")value <- c(0.86443, 0.79032, 0.86517, 0.79782, 0.79439, 0.89221, 0.93071, 0.87170, 0.86488, 0.91133, 0.87202, 0.84028, 0.83242, 0.74016, 0.86656)CT <- c("ET","ET","ET", "HP","HP","HP","HT","HT","HT", "LT","LT","LT","P","P","P")df<- cbind(gene,value,CT)df<- data.frame(df)So, I can make the scatter plot.ggplot(df, aes(x=CT, y=value)) + geom_point()How do I get a geom_line representing the means for each factor. I have tried the stat_summary:ggplot(df, aes(x=CT, y=value)) + geom_point() +stat_summary(aes(y = value,group = CT), fun.y=mean, colour="red", geom="line")But it does not work."geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?"But each group has three observations, what is wrong?Ps. I am also interested in a smooth line. 解决方案 You should set the group aes to 1:ggplot(df, aes(x=CT, y=value)) + geom_point() + stat_summary(aes(y = value,group=1), fun.y=mean, colour="red", geom="line",group=1) 这篇关于绘图意味着用ggplot绘制散点图上的线图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-29 04:02
查看更多