Author

Duc Nguyen

Published

July 19, 2026

1 Import

library(readxl)
df <- read_excel("data.xlsx")
df <- as.data.frame(df)
df
  RATIO CHI_TIEU VALUE LOWER_CI UPPER_CI
1 A:B 1   TREAT1  2.60     1.40     5.40
2 A:B 1   TREAT2 16.50     9.00    28.00
3 A:B 1   EFFECT 13.90     5.00    27.00
4 A:B 2   TREAT1  3.80     1.63     7.50
5 A:B 2   TREAT2 45.00    24.50    80.33
6 A:B 2   EFFECT 41.20    20.33    75.90
7 A:B 3   TREAT1  4.12     2.18     8.99
8 A:B 3   TREAT2 30.17    15.36    55.10
9 A:B 3   EFFECT 26.05    12.31    51.23
df$CHI_TIEU <- factor(df$CHI_TIEU,
                   levels = rev(c("TREAT1",
                              "TREAT2",
                              "EFFECT")))

2 Plot

library(ggplot2)

p1 <- ggplot(data = df,
       mapping = aes(x = VALUE,
                     y = CHI_TIEU)) +
  
  geom_errorbar(mapping = aes(xmin = LOWER_CI,
                              xmax = UPPER_CI),
                width = 0.1) +
  
  geom_point(shape = 21,
             color = "black",
             fill = "white") +
  
  
  
  facet_wrap(~ RATIO) +
  
  labs(x = "mg/L",
       y = "") +

  theme_bw(base_size = 16,
           ink = "black",
           paper = "white") +
  
  scale_y_discrete(breaks = c("TREAT1", "TREAT2", "EFFECT"),
                   labels = c(expression("3%"~NH[4]*Cl),
                              expression("6%"~NH[4]*Cl), 
                              expression(NH[4]*Cl~"effect"))) +

  theme(axis.title = element_text(color = "black")) +

  theme(axis.text = element_text(color = "black")) +
  
  theme(axis.ticks = element_line(color = "black")) +

  theme(strip.text = element_text(color = "black")) 
  
p1
ggsave(filename = "dot-plot.png",
       width = 9,
       height = 3,
       dpi = 300,
       units = "in")

3 Reference

https://themockup.blog/posts/2020-12-26-creating-and-using-custom-ggplot2-themes/

Để vẽ được các đồ thị khoa học đạt chuẩn công bố quốc tế, bạn có thể tham gia lớp R for Data Science do mình trực tiếp hướng dẫn. Thông tin chi tiết