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...
levels = variable) #排好序 ggplot(df)+ geom_half_violin(aes(as.numeric(factor(Species,levels = my_sort))+0.1, value,fill=factor(Species,levels = my_sort)), side = 'r',cex=0.8)+ #右侧半边显示 geom_boxplot(aes(as.numeric(factor(Species,levels = my_sort))+0.1, value,fill=factor...
ggplot(df,aes(cut,x,fill=cut))+ geom_flat_violin()+ theme(legend.position="none") 输出: 示例2:水平半小提琴情节 让我们看看使用 coord_flip() 函数水平对齐半小提琴图。 R实现 # Horizontal half violin plot ggplot(df,aes(cut,x,fill=cut))+ geom_flat_violin()+coord_flip()+ theme(legend....
这里主要介绍这个包中的geom_half_violin()函数,它相当于geom_violin()函数的变体,因为这个函数主要作用就是展示一半的小提琴图,然后与其他图形组合。 使用 geom_half_violin(mapping=NULL,data=NULL,stat="half_ydensity",position="dodge",...,side="l",nudge=0,draw_quantiles=NULL,trim=TRUE,scale="area"...
geom_half_violin() 最近在一个介绍ggplot2扩展包的链接里发现了一个包叫see,这个包里有一个函数是geom_violindot()函数,画云雨图非常方便,下面简单介绍一下代码 首先是安装see这个R包 代码语言:javascript 复制 install.package("see") 使用鸢尾花的数据集作图 ...
library(gghalves)ggplot(iris,aes(x=Species,y=Sepal.Width))+geom_half_point()+geom_point()head(my_data)ggplot()+geom_half_violin(data=my_data%>%filter(x=="a"& m=="i"),aes(x=x,y=y,fill=m),side="l")+geom_half_violin(data=my_data%>%filter(x=="a"& m=="j"),aes(x=x...
(width=0.2,fill="transparent",size=0.4,outlier.shape=NA)+# 添加箱线图,设置宽度、填充颜色、线条大小和异常值形状geom_half_violin(alpha=0.5,side='top')+# 添加半小提琴图,设置透明度和显示的一侧geom_half_point(side="l",alpha=0.1,size=0.6)+# 添加半点图,设置显示的一侧、透明度和大小scale_x_...
qplot(x,y,data,geom=c(xx,xx)) 条形图 barplot()第一个向量用来设定条形的高度,第二个向量用来设定每个条形对应的标签(可选)。 变量值条形图: 两个输入变量,x为分类变量,y表示变量值 频数条形图:一个输入变量,需要注意连续x轴和离散x轴的差异。 直方图 与条形图不同的地方在于,x为连续型变量 箱线图 ...
ggplot(数据, 映射) geom_xxx(映射, 数据) stat_xxx(映射, 数据) # 通过“+”实现不同图层的相应累加,且越往后的图层表现在上方 点(point, text):往往只有x、y指定位置,有shape但没有fill 线(line,vline,abline,hline,stat_function等):一般是基于函数来处理位置 ...
gghalvesadds_half_extensions to selectedgeoms: geom_half_boxplot geom_half_violin geom_half_point All of them have asideargument that can be eitherlfor left orrfor right half. As a special case there is alsogeom_half_dotplotto support half dotplots that dodge aesthetics such asfillandcolour...