我对编程很陌生,但我设法使用以下链接中的建议为散点图制作多面散点图和边际箱线图:http ://www.lreding.com/nonstandard_deviations/2017/08/19/cowmarg/
我的问题是如何在多面散点图上制作边际箱线图?
我的代码是:
CN<-read.csv("LfFlw.csv")
library(ggplot2)
简单的散点图:
ggplot(data=CN, aes(x=PlantOrder, y=CN, colour=Tissue))+geom_point()+facet_wrap(~Population, scales="free_x", nc=2)
黑白散点图:
sc<-ggplot(data=CN, aes(x=PlantOrder, y=CN, shape=Tissue))+geom_point()+facet_wrap(~Population, scales="free_x", nc=2)
sc
带有标记轴的散点图:
sc_lab<-sc+labs(x="Individual plants (ordered)", y="Cyanide (ug g^-1 dw)")
sc_lab
带有标记轴和经典主题的散点图:
sc_lab_th<-sc_lab+theme_classic()
sc_lab_th
带有标记轴的散点图和具有更改形状的经典主题:
s<-sc_lab_th+scale_shape_manual(values=c(8,2))
s
带有刻面和白色/灰色的箱线图:
y_box <- axis_canvas(s, axis = "y") + geom_boxplot(data = CN, outlier.shape = 1, aes(x = 0, y = CN, fill=Tissue)) +
facet_wrap(~Population, scales="free_x", nc=2)+scale_fill_manual(values=c("white", "grey"))
y_box
library(cowplot)
ggdraw(insert_yaxis_grob(s, y_box, position = "left"))
在这里我得到了一个错误:
get_panel(grob) 中的错误:绘图必须只包含一个面板