p <-ggplot(df2, aes(x=dose,y=len,group=supp))# 不同组不同线的类型和点的形状p + geom_line(aes(linetype = supp)) +geom_point(aes(shape = supp))# 增加颜色p + geom_line(aes(linetype=supp,color = supp))+geom_point(aes(shape=supp,color = supp))# 手动设置颜色p + geom_line(a...
15, 13, 40, 17) ) head(df2) ## sex time bill ## 1 Female breakfeast 10 ## 2 Female Lunch 30 ## 3 Female Dinner 15 ## 4 Male breakfeast 13 ## 5 Male Lunch 40 ## 6 Male Dinner 17 # Line plot with multiple
13. geom_abline(), geom_hline(), geom_vline() 14. geom_dotplot() 在ggplot2中, 通过用geom_*()替换一个不同的geom函数,你会得到一个不同类型的图形。这些几何图形是 ggplot2 的基本构件。它们本身非常有用,但也可用于构建更复杂的几何图形。这些几何体大多与一个命名的图块相关联:当该几何体在图...
ggplot(economics, aes(x=date)) + geom_line(aes(y = psavert), color = "darkred") + geom_line(aes(y = uempmed), color="steelblue", linetype="twodash") + theme_minimal()require(reshape2)df <- melt(economics[, c("date", "psavert", "uempmed")], id="date")ggplot(df,...
R语言ggplot2折线图(line plot)添加置信区间(CI)展示学术论文作者数量的变化趋势,非常有意思的数据可视化案例,原文提出的问题是学术论文中的作者数量有逐年增加的趋势;于是利用R语言里的rplos包抓取了Plos系列...
#默认分组设置, 即group=1 p + geom_boxplot() #分组(group)也是ggplot2种映射关系的一种, 如果需要把观测点按额外的离散变量进行分组处理, 必须修改默认的分组设置。 p1 <- ggplot(data=diamond, mapping=aes(x=carat, y=price, group=factor(cut))) ...
R语言ggplot2折线图(line plot)添加置信区间(CI)展示学术论文作者数量的变化趋势 非常有意思的数据可视化案例 ,原文提出的问题是学术论文中的作者数量有逐年增加的趋势;于是利用R语言里的rplos包抓取了 Plos 系列的6本期刊的2006年至2013年的每篇论文里的作者数量 进行可视化展示...
p+geom_boxplot() #分组(group)也是ggplot2种映射关系的一种, 如果需要把观测点按额外的离散变量进行分组处理, 必须修改默认的分组设置。 p1<-ggplot(data=diamond,mapping=aes(x=carat,y=price,group=factor(cut))) p1+geom_boxplot() 注意:不同的几何对象,要求的属性会有些不同,这些属性也可以在几何对象...
axis.line.y= element_line(size=1,linetype ='dotted'), axis.line.x=element_blank(), axis.text.x= element_text(vjust =0), plot.margin= unit(c(0.5,0.5,0.5,0.5),"cm"), legend.position= c(0.7,0.9), legend.text= element_text(color ="gray30") ...
axis.line.y= element_line(size=1,linetype ='dotted'), axis.line.x=element_blank(), axis.text.x= element_text(vjust =0), plot.margin= unit(c(0.5,0.5,0.5,0.5),"cm"), legend.position= c(0.7,0.9), legend.text= element_text(color ="gray30") ...