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)
相关推荐
关关钧1 天前
【R语言】聚类分析
开发语言·r语言
清同趣科研2 天前
扩增子分析|基于R包ggClusterNet包进行生态网络分析—十种可视化布局包括igraph,Gephi和maptree
开发语言·r语言
关关钧3 天前
【R语言】回归分析
开发语言·回归·r语言
Tiger Z4 天前
R 语言科研绘图第 24 期 --- 直方图-高亮
开发语言·程序人生·r语言·贴图
Biomamba生信基地5 天前
R语言学习计划启动
学习·r语言·生信
珏世佳人5 天前
GBD研究——美国州级地图(附资源)
r语言
yaoxin5211235 天前
第二十二章 P - R 开头的术语
linux·运维·r语言
qwy7152292581636 天前
8-R列表
windows·python·r语言
宠物与不尤编程7 天前
Python与R机器学习(1)支持向量机
python·机器学习·支持向量机·r语言
关关钧8 天前
【R语言】t检验
开发语言·r语言