基本图形 p <- ggplot(data=df, aes(x=dose, y=len, group=1))# 线加点p + geom_line() + geom_point()# 改变线的类型和颜色p + geom_line(linetype = "dashed", color = "steelblue")+ geom_point(color = "steelblue")# 用geom_step()函数p + geom_step() + geom_point()多组线图 ...
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,...
b3 <- base + geom_path(size = 8, lineend = "round", colour = "red") b4 <- base + geom_path(size = 8, linejoin = "mitre", lineend = "butt") plot_grid(b1, b2, b3, b4) 当线条的中间有NA值时,则会有一个断点 df <- data.frame(x = 1:5, y = c(1, 2, NA, 4, 5)...
ggplot(data,# Draw ggplot2 plot without colorsaes(x=x, y=y,group=group))+geom_line()+geom_point() By executing the previously shown R programming syntax, we have drawn Figure 1, i.e.a ggplot2 line and point graphicwithout any colors. Example 1: Modify Colors of Single Geom by Grou...
(axis.line.x = element_line(colour = 'grey50'), axis.ticks.x = element_line(colour = 'grey50'), axis.text = element_text(colour = 'grey50'), text = element_text(colour = 'grey50'), plot.title = element_text(colour = 'black'), axis.title.x = element_text(hjust = 0), ...
# Line plot with multiple groups # Change line types and colors by groups (sex) ggplot(df2, aes(x=time, y=bill, group=sex)) + geom_line(aes(linetype = sex, color = sex))+ geom_point(aes(color=sex))+ theme(legend.position="top") 1. 2. 3. 4. 5. 6. 同点一样,线也可以类...
df%>%ggplot(aes(year,lifeExp))+stat_boxplot(geom="errorbar",position=position_dodge(width=0.2),width=0.1)+geom_boxplot(position=position_dodge(width=0.2),width=0.4)+geom_line(aes(group=paired),position=position_dodge(0.2),color="grey80")+geom_point(aes(fill=year,group=paired,size=life...
函数ggplot()可以设置图形,但是没有视觉输出,需要使用一个或多个几何函数向图形中添加几何对象(geometric,简写为geom),包括点(point)、线(line)、条(bar)等,而添加几何图形的格式十分简单,通过符号“+”把几何图形添加到plot中: ggplot()+geom_xxx()
p + geom_boxplot() #分组(group)也是ggplot2种映射关系的一种, 如果需要把观测点按额外的离散变量进行分组处理, 必须修改默认的分组设置。 p1 <- ggplot(data=diamond, mapping=aes(x=carat, y=price, group=factor(cut))) p1 + geom_boxplot() ...
names.arg =means$Group.1, col=c('#BBFFFF','#AEEEEE','#96CDCD','#668B8B'), ylim=c(0,2)) lines(means$x,type = "b",pch=17,lty=2,col="red") #添加线条 #lines(x,y),相当于plot(x,y,type="1")? --- 4 棘状图 count<-table(Arthritis$Treatment,Arthritis$Improved) spine(co...