种类 | 种子类型 | 发芽时间 |
---|---|---|
A | 初始 | 10.5 |
A | 初始 | 11.3 |
B | 已存储 | 12.5 |
关于数据 有 34 种,2 种种子类型(存储的和初始的),发芽时间是数字。
我需要创建类似于附图的内容。最主要的是它需要使用ggplot来创建
我尝试使用以下代码来包装面板
plot2 <- ggplot(mydata, aes(x=factor(species), y=mgt,fill = species))+
geom_boxplot(outliers = F)+ theme(legend.position = "bottom")
plot3 <- plot2 + coord_flip()+ facet_wrap(seed_type) + scale_x_discrete(name = "Seed Type") + scale_y_continuous(name = "Germination Time")
plot3
但它没有创造出我想要的身材。
library(tidyverse)
# create some fake data
my_data <- data.frame(
species = sample(LETTERS[1:3], 100, replace = TRUE),
seed_type = sample(paste0("seed_type_", letters[1:8]), 100, replace = TRUE),
germination_time = runif(100, 10, 12.5)
)
head(my_data)
ggplot(my_data, aes(x = factor(species), y = germination_time, fill = species))+
geom_boxplot(outliers = F)+
theme(legend.position = "bottom") +
facet_wrap(~seed_type, ncol = 4) +
scale_x_discrete(name = "Species") +
scale_y_continuous(name = "Germination Time")