ggplot(data=data_bar,aes(x=types,y=disp,fill=types))+ geom_violin(alpha=0.5)+#绘制箱线图 geom_boxplot(fill="white",color="black",width=0.3,alpha=0.5)+#绘制箱线图 geom_jitter(width = 0.2,shape=21)+#width为横向抖动,不改变对应y值 scale_fill_brewer(palette = "Set2")+#对柱的填充...
p5 = ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) + geom_boxplot() p4|p5 同理,也可以使用以下函数手动更改箱线图填充颜色: scale_fill_manual() : 使用自定义颜色 scale_fill_brewer() :使用来自 RColorBrewer 包的调色板 scale_fill_grey() :使用灰色调色板 4.3修改图例位置和顺序 p + ...
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point(shape = 18, color = "steelblue", size = 4)fill可改变填充色,只适用于形状是21-25 ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point(shape = 23, fill = "blue", color = "darkred", size = 3)添加分组元素(默认 gg...
graph2 <- ggplot(test, aes(x = parameter, y = value, fill = sample, color = sample)) + scale_color_manual(values = c("black", "black", "white", "black", "black", "white")) + stat_boxplot(geom = "errorbar", position = position_dodge(width = 0.75), width = 0.2, show.l...
Change box plot fill colors In the R code below, box plot fill colors are automatically controlled by the levels ofdose: # Use single color ggplot(ToothGrowth, aes(x=dose, y=len)) + geom_boxplot(fill='#A4A4A4', color="black")+ theme_classic() # Change box plot colors by group...
)+ # 通过这个函数自定义颜色配置 scale_color_manual(values = c("#00AFBB", "#E7B800", "#FC4E07")) # 更改填充的颜色 p6...geom_boxplot(aes(fill = dose)) + scale_fill_manual(values = c("#00AFBB", "#E7B800", "#FC4E07")) # 对于color更改的是线的颜色...,对于fill更改的是...
e+geom_boxplot(notch = TRUE) 1. 按dose分组映射给颜色 e+geom_boxplot(aes(color=dose)) 1. 将dose映射给填充颜色 e+geom_boxplot(aes(fill=dose)) 1. 按supp进行分类并映射给填充颜色 ggplot(ToothGrowth, aes(x=dose, y=len))+ geom_boxplot(aes(fill=supp)) 1. 小提琴图 e+geom_violin(tri...
ggplot(data=Salaries,aes(x=rank, y=salary, fill=sex)) + geom_boxplot() + scale_x_discrete(breaks=c("AsstProf","AssocProf","Prof"), labels=c("Assistant\nProfessor", "Associate\nProfessor", "Full\nProfessor")) + scale_y_continuous(breaks=c(50000, 100000, 150000, 200000), ...
• 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() + coord_flip() • coord_quickmap()函数可以为地图设置合适的纵横比。当使用ggplot2绘制空间数据时,这个函数特别重要。 1 2 3 4 5 6 7 nz <-map_data("nz") ggplot(nz,aes(long, lat, group = group)) + geom_polygon(fill ="white", color ="black") + ...