geom_point(shape = 24,size = 6,fill = "red") +geom_point(shape = 24,size = 6,fill = "black", position = position_jitter(width = 0.5,height = 0.5,seed = 123)) 图中红色为默认位置,黑色为随机抖动点。 分组并排+抖动 大家如果经常绘制箱线图,还会接触到position_jitterdodge()函数,可实现...
ggplot(df, aes(x, y)) +geom_point() + geom_text(aes(label = y), position = position_nudge(y = -0.1)) 4 抖动(Jitter) 抖动位置调整是一种不定向的随机平移过程,对应的位置函数语法结构如下: position_jitter(width = NULL, height = NULL, seed = NA) width、height:横向、纵向抖动的最大幅...
geom_point(mapping = NULL, data = NULL, stat = "identity", position = "identity", na.rm = FALSE, ...) 从参数来看基本上也是常规的参数 下面来看些具体例子 1 2 3 library(ggplot2) p<-ggplot(economics,aes(pop,psavert)) p+geom_point() 1 p+geom_point(aes(color=pce)) 1 p+geom_poi...
ggplot(data1, aes(x = nitrogen, y = v2, colour = variety)) + geom_point(position = position_stack(vjust = 3)) # 散点图,stack,垂直堆叠放置,vjust参数调节。 image.png ggplot(data1,aes(x=nitrogen,y=v2,colour=variety))+geom_point(position=position_stack(reverse=T))# 柱状图,stack,rever...
geom_point(position = "jitter")+ scale_x_continuous(breaks = seq(0,21,1))#设置x轴范围从0到21,每一个单位显示一个刻度 p5 1. 2. 3. 4. 如果我们想要控制抖动的幅度 p6 <- ggplot(ChickWeight,aes(x=Time,y=weight))+ geom_point(position = position_jitter(width = 0.5,height = 0))+ ...
geom_node_point(size=22, aes(x=x, y=y)) + geom_node_text(size=16, color="white", fontface=2, vjust=0.4, aes(x=x, y=y, label=label)) + ## Set axis expand_limits(x=1, y=1) + coord_fixed() + ## Set legend scale_color_manual(name=tname, labels=plabel, values=pname...
ggplot(dsmall,aes(carat,price))+geom_point(aes(shape=cut))+scale_shape_manual(name='diamonds cut',values = c(1:5)) #1:5和基础绘图包中的形状是一一对应的 3. 点的大小 scale_size函数设置点的大小 p<-ggplot(mpg,aes(displ,hwy,size=hwy))+geom_point()p+scale_size(name='hwy size',break...
ggplot(mpg,aes(displ,hwy,colour=cty,shape=drv))+geom_point()+guides(colour=guide_colourbar(position="right"),shape=guide_legend(position="top"))+theme(legend.key.height=unit(1,"null"),legend.justification.top="right") 案例3 添加外部图 ...
p<-ggplot(data=mtcars,aes(x=mpg,y=wt,color=cyl,size=qsec,shape=gear))+geom_point()# 不设定specific aesthetic时候p 设置多个legend的位置 # 更改 legend positionp+theme(legend.position="bottom")# Horizontal legend boxp+theme(legend.position="bottom",legend.box="") ...
(Deprecated; last used in version 0.9.2) p + geom_point(aes(shape = factor(cyl))) + scale_shape(solid = FALSE) # Set aesthetics to fixed value p + geom_point(colour = "red", size = 3) qplot(wt, mpg, data = mtcars, colour = I("red"), size = I(3)) # Varying alpha is...