df <- data.frame(x = 0, y = levels(pbmc), stringsAsFactors = F ) df$y<- factor(df$y, levels = df$y) #通过shape选择自己想要的图例形状 p2 <- ggplot(df, aes(x, y, color = factor(y))) + geom_point(size = 6, shape = 18, show.
AI代码解释 p1<-p+theme(axis.text.x=element_text(color="red",size=14,angle=45,hjust=1,vjust=1),axis.text.y=element_text(color="blue","size=15",angle=90))p+p1 plot of chunk unnamed-chunk-12 修改坐标轴标签 直接使用name参数即可,或者也可以用xlba()/ylab() 代码语言:javascript 代码运行...
(0.1,'cm'),legend.key.width=unit(0.4,'cm'),legend.position="top",legend.text=element_text(color="black",size=8),legend.key.height=unit(0.4,'cm'),plot.margin=unit(c(0,0,0,0),units="cm"))+guides(fill=guide_legend(direction="horizontal"))+guides(fill=guide_legend(nrow=1,byrow=...
color = "black"), # 设置坐标轴文本样式 axis.title = element_text(size = 8) # 设置...
可以使用theme() 和 element_text()改变标题的性状,使用element_blank() 可以隐藏标题 例如 p +labs(title="Plot of length \n by dose", x ="Dose (mg)", y = "Teeth length")+ theme( plot.title = element_text(color="red", size=12, face="bold.italic"), axis.title.x =...
(0,1),labels=c("V型", "直列")) mtcars$cyl <- factor(mtcars$cyl) library(ggplot2) # 此处facet_grid使用双边模式am和vs ggplot(data=mtcars, aes(x=hp, y=mpg,shape=cyl, color=cyl)) + geom_point(size=3) + facet_grid(am~vs) + labs(title="mtcars网格图",x="马力", y="每加仑...
geom_smooth()函数增加了一条“平滑”曲线,需要 线性拟合(method="lm"),并且产生一条红色(color="red")虚线(linetype=2),线条尺寸为1(size=1)。默认情况下,平滑的曲线包括在95%的置信区间(较暗带)内。 4. ggplot2包提供了分组和小面化(faceting)的...
ggplot(data = diamond)+geom_point(aes(x=carat, y=price, colour=color)) ggplot(data = diamond) +geom_point(aes(x=carat, y=price, shape=cut)) ggplot(data = diamond) +geom_boxplot(aes(x=carat, y=price, group=factor(cut)))
ggplot(data=diamond)+geom_boxplot(aes(x=carat,y=price,group=factor(cut))) ggplot(data=diamond)+geom_point(aes(x=carat,y=price,colour=color,shape=cut)) 注:ggplot2支持图层,可以把不同的图层中共用的映射提供给ggplot函数,而某一几何对象才需要的映射参数提供给geom_xxx函数。
color='black') #3.2 变量分组绘图 --将分组变量映射给fill #3.2.1 不使用分面 #position = 'identity' 取消条形堆积进行垂直堆积,很有必要 library("MASS", lib.loc="D:/R/R-3.6.0/library") #str(birthwt) birthwt$smoke<-factor(birthwt$smoke) ...