R可视化:另类的箱线图

介绍

方格状态的箱线图

加载R包

{r} 复制代码
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)
library(patternplot)
library(png)
library(ggplot2)
library(gridExtra)

rm(list = ls())
options(stringsAsFactors = F)

导入数据

{r, 复制代码
data <- read.csv(system.file("extdata", "fruits.csv", package = "patternplot"))

准备数据

{r, 复制代码
group <- data$Fruit
y <- data$Weight
x <- data$Store

pattern.type <- c('nwlines', 'blank', 'waves')
pattern.color <- c('black','black', 'black')
background.color <- c('white','gray80', 'white')
frame.color <- c('black', 'black', 'black')
pattern.line.size <- c(6, 1,6)
density <- c(6, 1, 8)

画图

{r, 复制代码
box1 <- patternboxplot(
  data, x, y, group = group,
  pattern.type = pattern.type,
  pattern.line.size = pattern.line.size, 
  label.size = 3, 
  pattern.color = pattern.color, 
  background.color = background.color,
  frame.color = frame.color,
  density = density,  
  legend.h = 2, 
  legend.x.pos = 1.075, 
  legend.y.pos = 0.499, 
  legend.pixel = 10,
  legend.w = 0.18, 
  legend.label = c("Orange","Strawberry","Watermelon")) +
  ggtitle('(A) Boxplot with Black and White Patterns')

pattern.color <- c('black','white', 'grey20')
background.color <- c('gold','lightpink', 'lightgreen')

box2 <- patternboxplot(
  data, x, y, group = group,
  pattern.type = pattern.type,
  pattern.line.size = pattern.line.size, 
  label.size = 3,
  pattern.color = pattern.color, 
  background.color = background.color,
  frame.color = frame.color, 
  density = density,
  legend.h = 2, 
  legend.x.pos = 1.075, 
  legend.y.pos = 0.499, 
  legend.pixel = 10,
  legend.w = 0.18, 
  legend.label = c("Orange","Strawberry","Watermelon")) +
  ggtitle('(B) Boxplot with Colors and Patterns')

grid.arrange(box1, box2, nrow = 1)
相关推荐
山居秋暝LS2 小时前
【无标题】RTX00安装paddle OCR,win11不能装最新的,也不能用GPU
开发语言·r语言
m0_748839499 小时前
R包grafify:简单操作实现高效统计绘图
开发语言·r语言
AI2中文网1 天前
App Inventor 2 向心力实验App - 探究向心力F与角速度ω、半径r、质量m的关系
前端·javascript·r语言
生物信息与育种1 天前
PlantBiMoE开源:轻量高效的植物基因组基础模型
人工智能·深度学习·职场和发展·数据分析·r语言
Michelle80231 天前
24大数据 12-1 条形图
r语言
Sylvia-girl2 天前
R语言概述
开发语言·r语言
雁迟2 天前
第十三章:R 读取 txt、csv 表格数据
r语言
Biomamba生信基地3 天前
R语言scRNA-seq去RNA污染手册
r语言·单细胞测序·scrna-seq
Omics Pro3 天前
全流程可重复!R语言脂质组学:原始数据→功能解析
开发语言·人工智能·深度学习·语言模型·r语言·excel·知识图谱
雁迟3 天前
第八章:矩阵与数组操作
线性代数·矩阵·r语言