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...
(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), ...
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,...
theme(plot.title=element_text(face="bold.italic",color="steelblue",size=24, hjust=0.5,vjust=0.5,angle=360,lineheight=113)) 下面为theme的相关参数,可以细节修改处,之后的后面会继续补充。 function (base_size = 12, base_family = "") { theme(line = element_line(colour = "black", size = ...
ggplot(data,# Change colors of lines & points by groupaes(x=x, y=y, col=group))+geom_line()+geom_point() As shown in Figure 3, the previous code has created a new ggplot2 plot where all colors have been changed by group.
条形图使用 geom_bar (),折线图使用 geom_line (),箱线图使用 geom_boxplot (),散点图使用 geom_point ()。函数 geom_point () 向图中添加一个点层,从而创建散点图。 ggplot( data = penguins, mapping = aes(x = flipper_length_mm, y = body_mass_g) ) + geom_point() #> Warning: ...
# 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. 同点一样,线也可以类...
p+geom_boxplot() #分组(group)也是ggplot2种映射关系的一种, 如果需要把观测点按额外的离散变量进行分组处理, 必须修改默认的分组设置。 p1<-ggplot(data=diamond,mapping=aes(x=carat,y=price,group=factor(cut))) p1+geom_boxplot() 注意:不同的几何对象,要求的属性会有些不同,这些属性也可以在几何对象...
length = 0.01)+ scale_size_continuous(range=c(1,3))+ scale_fill_manual(values=c("#3CB2EC","#9C8D58"))+ labs(x=NULL,y=NULL)+ theme_test()+ theme(plot.margin=unit(c(0,0.5,0.5,0.5),units=,"cm"), axis.line = element_line(color = "black",size = 0.3), panel.grid.minor ...
函数ggplot()可以设置图形,但是没有视觉输出,需要使用一个或多个几何函数向图形中添加几何对象(geometric,简写为geom),包括点(point)、线(line)、条(bar)等,而添加几何图形的格式十分简单,通过符号“+”把几何图形添加到plot中: ggplot()+geom_xxx()