Dibujar un diagrama de caja simple en lenguaje R

Dibujar un diagrama de caja simple en lenguaje R

Después de ser presentado por un amigo, escribí un blog por primera vez, dejando un párrafo para registrar este momento.

#计算天尺度的Q10值
Daytime <- c(1.45, 1.40, 1.37, 1.33, 1.45, 1.30)
Nighttime <- c(1.40, 1.35, 1.37, 1.36, 1.40, 1.37)

Diurnal <- data.frame(Daytime, Nighttime)
Diurnal

library(reshape2)
dfDay <- melt(Diurnal)
dfDay

library(ggplot2)
library(ggsignif)

p1 <- ggplot(dfDay, aes(x = factor(variable), y = value)) + 
  ggtitle("(a)Diurnal") +
  ylab("Q10") +
  stat_boxplot(geom = 'errorbar', width = 0.2) +
  geom_boxplot(shape = "Type") +
  geom_point(shape = 21, size = 1.5) +
  ylim(1.28, 1.5) +
  theme(plot.title = element_text(vjust = -10, hjust = 0.03)) +
  theme(axis.text.x = element_text(size = rel(1.5))) + 
  theme(axis.text.y = element_text(size = rel(1.5))) + 
  theme(axis.title.y = element_text(size = 14)) + 
  theme(axis.title.x = element_blank()) + 
  theme(panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        panel.background = element_blank(), 
        axis.line = element_line(colour = "black"),
        panel.border = element_rect(colour = "black", fill = NA))
p1

#计算季节尺度的Q10值
Spring <- c(NA, 1.97, 1.69, 2.20, 1.53, 2.01, 2.41)
Summer <- c(1.28, 1.21, 0.92, 0.75, 1.44, 1.10, 1.05)
Autumn <- c(2.20, 2.37, 2.24, 2.14, 3.26, 2.52, NA)
Winter <- c(1.30, 1.34, 1.09, 1.23, 1.77, 1.13, NA)

Seasonal <- data.frame(Spring, Summer, Autumn, Winter)
Seasonal

dfseason <- melt(Seasonal)
dfseason

p2 <- ggplot(dfseason, aes(x = factor(variable), y = value)) + 
  ggtitle("(b)Seasonal") +
  stat_boxplot(geom = 'errorbar', width = 0.2) +
  geom_boxplot(shape = "Type") +
  geom_point(shape = 21, size = 1.5) +
  theme(plot.title = element_text(vjust = -10, hjust = 0.03)) +
  theme(axis.text.x = element_text(size = rel(1.5))) + 
  theme(axis.text.y = element_text(size = rel(1.5))) + 
  theme(axis.title.y = element_blank()) + 
  theme(axis.title.x = element_blank()) + 
  theme(panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        panel.background = element_blank(), 
        axis.line = element_line(colour = "black"),
        panel.border = element_rect(colour = "black", fill = NA))
p2

library(patchwork)
p1 + p2 

suplemento

Actualizaré mi blog de vez en cuando en el futuro. Espero poder publicar más artículos en el nuevo año, ¡y el lenguaje R irá más allá!

¡El objetivo final es usar R para dibujar "la estrella de la oveja"! Jajaja.

¡Deseo que todos se vuelvan más fuertes!

¡Finalmente, gracias @ 桃子 鱼 gis por su entusiasta patrocinio!
Inserte la descripción de la imagen aquí

Supongo que te gusta

Origin blog.csdn.net/m0_46461702/article/details/112391833
Recomendado
Clasificación