position = position_jitter(width = 0.5, height = 0.1, seed = 123)) 此外,position_jitterdodge()函数可实现分组并排后再进行抖动。语法结构如下: position_jitterdodge( jitter.width = NULL, jitter.height = 0, dodge.width = 0.75, seed = NA ) 示例如下: ggplot(mtcars, aes(x = factor(cyl), ...
position_jitterdodge( jitter.width = NULL, jitter.height = 0, dodge.width = 0.75, seed = NA) 各个参数意义结合上述的position_dodge和position_jitter都可以猜到。 p42 <- ggplot(ToothGrowth,aes(x = supp,y = len,fill = factor(dose))) + geom_boxplot() + #position = "dodge2"\position ...
b <- ggplot(df,aes(x,y))+geom_point()+geom_text(aes(label=y), position=position_nudge(y=-0.1)) grid.arrange(a,b,ncol=2) 1. 2. 3. 4. 5. 6. 7. 8. 4.有规则扰动 同样只能作为函数position_jitterdodge使用。 同一组内,红色点只出现在红色盒形上,不会出现在其他位置。
mapping =aes(x = cut, fill = clarity), position ="dodge" ) 通过将位置调整方式设为“抖动”,可以避免这种网格化排列。position = "jitter"为每个数据点添加一个很小的随机扰动,这样就可以将重叠的点分散开来,因为不可能有两个点会收到同样的随机扰动。可用geom_point(position = "jitter")的一种快速实现...
代码语言:javascript 代码运行次数:0 运行 AI代码解释 set.seed(1)ggplot(data,aes(x,y,fill=fill))+geom_boxplot()+geom_point(aes(shape=shape,group=fill),position=position_jitterdodge())
当散点图其中一个数据轴对应离散型变量时,也会出现数据重叠的情况,这时可以调用position_jitter()函数给数据点增加随机扰动,默认情况下,该函数在每个方向上添加的扰动值为数据点最小精度的40%,不过,也可以通过width 和height 参数对该值进行调整。 sp1 <- ggplot(ChickWeight, aes(x=Time, y=weight)) ...
map + geom_star(data=dat01, aes(x=Longitude,y=Latitude, starshape=Land_use, color=`AamoA/nir`, fill=`AamoA/nir`), size=4, position = position_jitter(width = 10, height = 10, seed = 1234))+ scale_starshape_manual(values=c(11:15,20,9))+ scale_fill_gradient2(low = "#429...
p+ geom_jitter(shape=16, position=position_jitter(0.2)) 7,旋转箱线图 函数coord_flip()用于翻转笛卡尔坐标系,使水平变为垂直,垂直变为水平,主要用于把显示y条件x的geoms和统计信息转换为x条件y。 p <- ggplot(ToothGrowth, aes(x=dose, y=len)) +geom_boxplot()+coord_flip() ...
•Key functions:geom_jitter(), stat_summary()•Key arguments to customize the plot:alpha, color, shape, size and fill.基础用法 # 基础图e + geom_jitter()# 改变点的位置 0.2表示震动幅度e + geom_jitter(position = position_jitter(0.2))# 改变点的形状和大小e + geom_jitter(position=...
position=position_jitterdodge(jitter.width = 0.35, jitter.height = 0, dodge.width = 0.8))+ geom_boxplot(alpha=0.2,width=0.45, position=position_dodge(width=0.8), size=0.75,outlier.colour = NA)+ geom_violin(alpha=0.2,width=0.9,