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)
相关推荐
Katecat996632 天前
【深度学习】基于Mask R-CNN的帽子佩戴检测与分类详解(附改进模型+源码)
深度学习·r语言·cnn
Lun3866buzha5 天前
内窥镜设备部件检测与识别——基于Mask R-CNN的改进模型训练与实现
开发语言·r语言·cnn
啊辉的科研6 天前
植物单细胞RNA-seq分析教程3-2025年版
linux·r语言
Lun3866buzha6 天前
人员跌倒检测系统:基于Faster R-CNN的改进模型实现与优化_1
开发语言·r语言·cnn
啊辉的科研6 天前
植物单细胞RNA-seq分析教程4-2025年版
数据分析·r语言
TjlIlSzJbh7 天前
Matlab利用BP神经网络进行气象预测与天气精准预测:多维映射与误差最小化算法实现
r语言
Faker66363aaa7 天前
工业场景下护目镜佩戴检测与安全合规性评估_Faster_R-CNN_X101-32x4d_FPN_PISA模型详解
安全·r语言·cnn
WW、forever7 天前
【服务器-R环境配置】导出配置文件并重建
运维·服务器·r语言
Faker66363aaa8 天前
使用Faster R-CNN实现胚胎发育阶段自动检测与分类——基于R50-FPN模型与COCO数据集训练
分类·r语言·cnn