美文网首页
r 画箱线图

r 画箱线图

作者: 球果假水晶蓝 | 来源:发表于2023-01-31 16:47 被阅读0次
    library(ggplot2)
    
    # create a data frame
    variety=rep(LETTERS[1:7], each=40)
    treatment=rep(c("high","low"),each=20)
    note=seq(1:280)+sample(1:150, 280, replace=T)
    data=data.frame(variety, treatment ,  note)
    
    # https://blog.csdn.net/Judezhl/article/details/108592803 字体类型设置
    # https://zhuanlan.zhihu.com/p/548042858 字体大小设置
    # grouped boxplot
    
    fig = ggplot(data, aes(x=variety, y=note, fill=treatment))
    +labs(title="Miles per gallon according to the weight",x="type", y = "number")
    +geom_boxplot()
    + theme_classic() # 去除背景
    +theme(text=element_text("serif"),
    plot.title = element_text(hjust = 0.5,size = 20), # 标题属性
    axis.title = element_text(hjust = 0.5,size = 15))# 坐标轴属性
    
    fig.png

    http://r-graph-gallery.com/
    https://plotly.com/r/
    https://r-charts.com/

    相关文章

      网友评论

          本文标题:r 画箱线图

          本文链接:https://www.haomeiwen.com/subject/xohbhdtx.html