p+geom_boxplot(aes(fill=jobcat))+labs(title="不同职位类别薪资分布",x="职位类别", y = "当前薪资") 3.散点箱线图 目标:在分组箱线图基础上添加散点,提高统计图形的可读性。 p+geom_boxplot()+geom_jitter(width = 0.2, alpha = 0.5, color = 'red') jitter可以理解
ggplot(data=data_bar,aes(x=types,y=disp,fill=types))+ geom_half_violin(alpha=0.5)+#绘制半个小提琴图 geom_boxplot(fill="white",color="black",position = position_nudge(x=-0.05), width=0.1,alpha=0.5)+#绘制箱线图 geom_jitter(width = 0.2,shape=21)+#width为横向抖动,不改变对应y值 sca...
在用ggplot画图的过程中,我们常常希望能够循环某个变量同时画很多图。如我们的数据是testdata 如果我们按stage来画某个基因的表达: ggplot(testdata,aes(x = stage,y = Myh6,fill = stage))+geom_boxplot() 如果我们想不断遍历所有的基因,aes里面填写是参数,而我们通常填入的列名是character,这个时候用到字符...
fill可改变填充色,只适用于形状是21-25 ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point(shape = 23, fill = "blue", color = "darkred", size = 3)添加分组元素(默认 ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point(aes(shape = cyl, color = cyl))也可以用以下函数...
shape = NA,width=0.5) + stat_boxplot(geom = "errorbar", aes(ymin = ..ymax..),width=0.2,size=0.35) + stat_boxplot(geom = "errorbar", aes(ymax = ..ymin..),width=0.2,size=0.35) + geom_boxplot_pattern(aes(pattern = year,pattern_angle = year,fill=year), pattern = 'tiling...
• Key function: geom_boxplot()• Alternative function: stat_boxplot()• Key arguments to customize the plot: alpha, color, linetype, shape, size and fill 基本的箱图 e + geom_boxplot()旋转的箱图 e + geom_boxplot() + coord_flip()凹陷的箱图(缺口显示中位数以及置信区间)e + ...
参数:geom_boxplot()# 箱图 plot1 = ggplot(input, aes(x=X2, y=value, fill=X2)) + # 添加数据、xy值、 颜色 geom_boxplot() + # 盒图 labs(x="指标(x轴)", y="值", fill="指标(图例)") + # 设置xy轴和图例的标题 theme(panel.grid=element_blank(), panel.background=element_rect...
geom_boxplot(fill='orange') #1.2 箱形图设置异常点及图形调色(outlier.x参数控制异常点) ggplot(singer,aes(x=voice.part,y=height)) + geom_boxplot(fill = "white", color = "darkgreen", outlier.color = "red", #控制边线颜色 outlier.fill = "orange", ...
卡槽设置。 #卡槽p<-ggplot(mpg,aes(class,hwy))p+geom_boxplot(notch=T)#卡槽超出了盒子边缘#宽度p+geom_boxplot(varwidth=T) 颜色设置。 #颜色p+geom_boxplot(fill='forestgreen',color='black') #映射变量p+geom_boxplot(aes(color=drv))...
二:调用几何函数geom函数在视觉上表现变量,目前有37个gemo函数 常用几何函数 参数详解 示例1: # car包的Salaries数据集,包含了大学教授的收入信息。 install.packages("car") library(car) ggplot(Salaries,aes(x=rank,y=salary)) + geom_boxplot(fill="#00DDAA",color = "black", notch = T) + ...