## Them font chu
library(showtext)
## Loading required package: sysfonts
## Loading required package: showtextdb
font_add("Times New Roman", "times.ttf")  # Đường dẫn tới file font Times New Roman
font_add("Arial", "arial.ttf")
font_add("Times New Roman Bold", "timesbd.ttf")
showtext_auto()

library(ggplot2)
library(viridis)
## Loading required package: viridisLite
library(ggthemes)


library(readxl)
Force_ECAPPC_F100L15 <- read_excel("~/1.Detai_Caohoc/5.Mo_Phong/2.File_MoPhong/3.GhepCon_KenhSS/8.K2_50x50x10_KenhSS/Force_ECAPPC_F100L15.xlsx", 
                                   col_types = c("numeric", "numeric", "numeric", 
                                                 "text"))
head(Force_ECAPPC_F100L15)
## # A tibble: 6 × 4
##   `Distance, mm` `Load, tf` `Hành trình` Type    
##            <dbl>      <dbl>        <dbl> <chr>   
## 1           49.9      0            0     Chu kỳ 1
## 2           49.1      0.306        0.788 Chu kỳ 1
## 3           48.9      0.530        1.01  Chu kỳ 1
## 4           48.8      0.735        1.09  Chu kỳ 1
## 5           48.4      1.15         1.53  Chu kỳ 1
## 6           48.1      1.56         1.84  Chu kỳ 1
#Cần xem bảng thì view()


library(readxl)
Force_ECAPPC_F100L15_2WP <- read_excel("~/1.Detai_Caohoc/5.Mo_Phong/2.File_MoPhong/3.GhepCon_KenhSS/8.K2_50x50x10_KenhSS/Force_ECAPPC_F100L15.xlsx", 
    sheet = "LucECAPPC_2WP", col_types = c("numeric", 
        "numeric", "numeric", "text"))
head(Force_ECAPPC_F100L15_2WP)
## # A tibble: 6 × 4
##   `Distance, mm` `Load, tf` `Hành trình` Type    
##            <dbl>      <dbl>        <dbl> <chr>   
## 1           55.9      0            0     Chu kỳ 1
## 2           55.7      0.137        0.224 Chu kỳ 1
## 3           55.6      0.163        0.284 Chu kỳ 1
## 4           55.6      0.515        0.328 Chu kỳ 1
## 5           55.4      7.68         0.452 Chu kỳ 1
## 6           55.3      9.98         0.609 Chu kỳ 1
# Đồ thị lực ECAP PC
#1. ECAPPC_50x50x10_1WP

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
ggplot(Force_ECAPPC_F100L15) +
  aes(x = `Hành trình`, y = `Load, tf`, colour = Type, group = Type) +
  geom_line() +
  geom_point(aes(shape = Type, color = Type, group = Type, x = `Hành trình`, y = `Load, tf`), alpha = 1, size = 1.5) +
  scale_color_hue(direction = 1) +
  scale_x_continuous(limits = c(0, 50), breaks = seq(0, 50, by = 5)) +
  scale_y_continuous(limits = c(0, 45), breaks = seq(0, 45, by = 5)) +
  labs(x = "Hành trình (mm)", y = "Lực (tấn)", title = "Đồ thị lực khuôn ghép côn") +
  coord_fixed(ratio = 0.75) + # Tỷ lệ chiều dài trục y/x
  theme_bw() +
  theme(
    panel.grid.minor.x = element_blank(),  # Loại bỏ đường lưới dọc nhỏ
    panel.grid.minor.y = element_blank(),  # Loại bỏ đường lưới dọc nhỏ
    panel.grid.major.x = element_line(color = "gray", linewidth = 0.55, linetype = "dashed"),  # Thêm đường lưới dọc nét đứt
    panel.grid.major.y = element_line(color = "gray", linewidth = 0.55, linetype = "dashed"),  # Thêm đường lưới ngang nét đứt
    panel.border = element_blank(),  # Loại bỏ viền 4 cạnh
    axis.line = element_line(color = "black", linewidth = 0.5),  # Thêm axis lines đen mỏng chỉ cho x và y
    #panel.border = element_rect(color = "black", fill = NA, linewidth = 1),  # Thêm viền đen đậm 4 canh
    axis.text = element_text(color = "black", size = 14),  # Chữ trên trục màu đen
    axis.title = element_text(color = "black", size = 14))+   # Tiêu đề trục màu đen
  theme(plot.title = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", hjust = 0.5), #hjust là căn giữa tiêu đề
      axis.title.y = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", vjust = 2, margin = margin(r = 5)), 
      axis.title.x = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", vjust = -2), 
      axis.text.y = element_text(family = "Times New Roman", size = 14L, face = "plain"),   # Chữ trên trục đen không đậm
      axis.text.x = element_text(family = "Times New Roman", size = 14L, face = "plain"))+  # Chữ trên trục đen không đậm
  theme(legend.title = element_text(family = "Times New Roman", size = 14L),
        legend.text = element_text(family = "Times New Roman", size = 14L))+
  theme(
    legend.position = c(0.85, 0.3),  # Đặt tọa độ legend trong khung đồ thị
    legend.background = element_rect(color = "black", fill = "white"), # Thêm nền và viền
    legend.key.size = unit(1.5, "lines"),
    legend.title.align = 0.5,
    legend.title = element_blank(),
    plot.title = element_blank()) # Ẩn tiêu đề đồ thị
## Warning: The `legend.title.align` argument of `theme()` is deprecated as of ggplot2
## 3.5.0.
## ℹ Please use theme(legend.title = element_text(hjust)) instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: A numeric `legend.position` argument in `theme()` was deprecated in ggplot2
## 3.5.0.
## ℹ Please use the `legend.position.inside` argument of `theme()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

# Cần xem giá trị thì:
#DT1 =ggplot(Force_ECAPPC_F100L15)
#ggplotly(DT1)
#2. ECAPPC_50x50x10_2WP

library(dplyr)

ggplot(Force_ECAPPC_F100L15_2WP) +
  aes(x = `Hành trình`, y = `Load, tf`, colour = Type, group = Type) +
  geom_line() +
  geom_point(aes(shape = Type, color = Type, group = Type, x = `Hành trình`, y = `Load, tf`), alpha = 1, size = 1.5) +
  scale_color_hue(direction = 1) +
  scale_x_continuous(limits = c(0, 55), breaks = seq(0, 55, by = 5)) +
  scale_y_continuous(limits = c(0, 55), breaks = seq(0, 55, by = 5)) +
  labs(x = "Hành trình (mm)", y = "Lực (tấn)", title = "Đồ thị lực khuôn ghép côn") +
  coord_fixed(ratio = 0.75) + # Tỷ lệ chiều dài trục y/x
  theme_bw() +
  theme(
    panel.grid.minor.x = element_blank(),  # Loại bỏ đường lưới dọc nhỏ
    panel.grid.minor.y = element_blank(),  # Loại bỏ đường lưới dọc nhỏ
    panel.grid.major.x = element_line(color = "gray", linewidth = 0.55, linetype = "dashed"),  # Thêm đường lưới dọc nét đứt
    panel.grid.major.y = element_line(color = "gray", linewidth = 0.55, linetype = "dashed"),  # Thêm đường lưới ngang nét đứt
    panel.border = element_blank(),  # Loại bỏ viền 4 cạnh
    axis.line = element_line(color = "black", linewidth = 0.5),  # Thêm axis lines đen mỏng chỉ cho x và y
    #panel.border = element_rect(color = "black", fill = NA, linewidth = 1),  # Thêm viền đen đậm 4 canh
    axis.text = element_text(color = "black", size = 14),  # Chữ trên trục màu đen
    axis.title = element_text(color = "black", size = 14))+   # Tiêu đề trục màu đen
  theme(plot.title = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", hjust = 0.5), #hjust là căn giữa tiêu đề
      axis.title.y = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", vjust = 2, margin = margin(r = 5)), 
      axis.title.x = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", vjust = -2), 
      axis.text.y = element_text(family = "Times New Roman", size = 14L, face = "plain"),   # Chữ trên trục đen không đậm
      axis.text.x = element_text(family = "Times New Roman", size = 14L, face = "plain"))+  # Chữ trên trục đen không đậm
  theme(legend.title = element_text(family = "Times New Roman", size = 14L),
        legend.text = element_text(family = "Times New Roman", size = 14L))+
  theme(
    legend.position = c(0.85, 0.3),  # Đặt tọa độ legend trong khung đồ thị
    legend.background = element_rect(color = "black", fill = "white"), # Thêm nền và viền
    legend.key.size = unit(1.5, "lines"),
    legend.title.align = 0.5,
    legend.title = element_blank(),
    plot.title = element_blank()) # Ẩn tiêu đề đồ thị

# Đồ thị lực ECAPPC_505010 tổng hợp theo Group

library(readxl)
library(dplyr)
library(ggplot2)
library(tidyr)

# Đọc dữ liệu từ file Excel (giả sử file nằm trong working directory)
Force_ECAPPC_505010 <- read_excel("~/0.Caohoc_Phuong/3.Ky2_1/6.BDDManhLiet/Force_ECAPPC_505010.xlsx", 
    sheet = "LucECAPPC_505010", col_types = c("numeric", "numeric", "numeric", "text", "text"))
head(Force_ECAPPC_505010)
## # A tibble: 6 × 5
##   `Distance, mm` `Load, tf` `Hành trình` Type    Group
##            <dbl>      <dbl>        <dbl> <chr>   <chr>
## 1           49.2    0.0116         0     Φ75; 1d Φ75  
## 2           49.0    0.00491        0.188 Φ75; 1d Φ75  
## 3           48.6    0.370          0.542 Φ75; 1d Φ75  
## 4           48.3    0.892          0.880 Φ75; 1d Φ75  
## 5           48.0    1.17           1.15  Φ75; 1d Φ75  
## 6           47.8    1.49           1.36  Φ75; 1d Φ75
# Tạo dữ liệu chú thích: các Type unique per Group, với vị trí y xếp chồng
annotation_data <- Force_ECAPPC_505010 %>%
  group_by(Group) %>%
  summarise(types = list(unique(Type)), .groups = 'drop') %>%
  unnest(types) %>%
  group_by(Group) %>%
  mutate(y_pos = seq(15, 15 - 5 * (n() - 1), by = -5))  # Vị trí y giảm dần cho các chú thích

# Tạo dữ liệu cho khung rectangle per Group, đảm bảo bao chùm các chú thích
rect_data <- annotation_data %>%
  group_by(Group) %>%
  summarise(
    xmin = 34,  # Vị trí x bắt đầu khung (điều chỉnh để rộng hơn)
    xmax = 46,  # Vị trí x kết thúc khung (điều chỉnh để rộng hơn)
    ymin = min(y_pos) - 3,  # Padding dưới để bao chùm tốt hơn
    ymax = max(y_pos) + 3,  # Padding trên để bao chùm tốt hơn
    .groups = 'drop'
  )

# Lấy danh sách các Type duy nhất để định dạng
unique_types <- unique(Force_ECAPPC_505010$Type)

# Vẽ biểu đồ tổng hợp với facet_wrap theo Group
ggplot(Force_ECAPPC_505010) +
  aes(x = `Hành trình`, y = `Load, tf`, colour = Type, group = Type, linetype = Type, shape = Type) +
  geom_line(size = 1) +  # Tăng độ dày đường để dễ nhìn
  geom_point(alpha = 1, size = 0.5) +  # Tăng kích thước điểm để dễ nhìn
  # Vẽ khung rectangle (nền trắng, viền đen)
  geom_rect(data = rect_data, aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax),
            fill = "white", color = "black", inherit.aes = FALSE, alpha = 0.8) +
  # Vẽ text chú thích bên trong khung, màu theo Type
  geom_text(data = annotation_data, aes(x = 40, y = y_pos, label = types, colour = types),
            size = 4, hjust = 0.5, inherit.aes = FALSE) +  # Căn giữa text
  # Định dạng kiểu đường, hình dạng điểm, và màu sắc
  scale_linetype_manual(values = c("solid", "twodash", "dashed", "longdash", "solid", "twodash", "dashed", "solid")[1:length(unique_types)]) +
  scale_shape_manual(values = c(18, 17, 2, 19, 15, 2, 13, 4, 2, 2, 3, 2)) +
  scale_color_manual(values = c("darkgreen", "red", "blue", "darkgreen", "red", "blue", "darkgreen", "red", "blue", "darkgreen","red","blue")) +
  scale_x_continuous(limits = c(0, 50), breaks = seq(0, 50, by = 5)) +
  scale_y_continuous(limits = c(0, 55), breaks = seq(0, 55, by = 5)) +
  labs(x = "Hành trình (mm)", y = "Lực (tấn)", title = "Đồ thị lực khuôn ghép côn") +
  coord_fixed(ratio = 0.75) +
  theme_bw() +
  theme(
    panel.grid.minor.x = element_blank(),
    panel.grid.minor.y = element_blank(),
    panel.grid.major.x = element_line(color = "gray", linewidth = 0.25, linetype = "dashed"),
    panel.grid.major.y = element_line(color = "gray", linewidth = 0.25, linetype = "dashed"),
    panel.border = element_blank(),
    axis.line = element_line(color = "black", linewidth = 0.5),
    axis.text = element_text(color = "black", size = 14),
    axis.title = element_text(color = "black", size = 14),
    plot.title = element_text(family = "Times New Roman Bold", size = 14, face = "bold", hjust = 0.5),
    axis.title.y = element_text(family = "Times New Roman Bold", size = 14, face = "bold", vjust = 2, margin = margin(r = 5)),
    axis.title.x = element_text(family = "Times New Roman Bold", size = 14, face = "bold", vjust = -2),
    axis.text.y = element_text(family = "Times New Roman", size = 14, face = "plain"),
    axis.text.x = element_text(family = "Times New Roman", size = 14, face = "plain"),
    legend.position = "none"  # Ẩn legend
  ) +
  facet_wrap(vars(`Group`))
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

# Đồ thị lực ECAPPC_505010 tổng hợp theo Group

library(readxl)
library(dplyr)
library(ggplot2)
library(tidyr)

# Đọc dữ liệu từ file Excel (giả sử file nằm trong working directory)
Force_ECAPPC_505010 <- read_excel("~/0.Caohoc_Phuong/3.Ky2_1/6.BDDManhLiet/Force_ECAPPC_505010.xlsx", 
    sheet = "LucECAPPC_505010", col_types = c("numeric", "numeric", "numeric", "text", "text"))
head(Force_ECAPPC_505010)
## # A tibble: 6 × 5
##   `Distance, mm` `Load, tf` `Hành trình` Type    Group
##            <dbl>      <dbl>        <dbl> <chr>   <chr>
## 1           49.2    0.0116         0     Φ75; 1d Φ75  
## 2           49.0    0.00491        0.188 Φ75; 1d Φ75  
## 3           48.6    0.370          0.542 Φ75; 1d Φ75  
## 4           48.3    0.892          0.880 Φ75; 1d Φ75  
## 5           48.0    1.17           1.15  Φ75; 1d Φ75  
## 6           47.8    1.49           1.36  Φ75; 1d Φ75
# Tạo dữ liệu chú thích: các Type unique per Group, với vị trí y xếp chồng
annotation_data <- Force_ECAPPC_505010 %>%
  group_by(Group) %>%
  summarise(types = list(unique(Type)), .groups = 'drop') %>%
  unnest(types) %>%
  group_by(Group) %>%
  mutate(y_pos = seq(15, 15 - 5 * (n() - 1), by = -5))  # Vị trí y giảm dần cho các chú thích

# Tạo dữ liệu cho khung rectangle per Group, đảm bảo bao chùm các chú thích
rect_data <- annotation_data %>%
  group_by(Group) %>%
  summarise(
    xmin = 28,  # Vị trí x bắt đầu khung
    xmax = 50,  # Vị trí x kết thúc khung
    ymin = min(y_pos) - 3,  # Tăng padding dưới để bao chùm tốt hơn
    ymax = max(y_pos) + 3,  # Tăng padding trên để bao chùm tốt hơn
    .groups = 'drop'
  )

# Lấy danh sách các Type duy nhất để định dạng
unique_types <- unique(Force_ECAPPC_505010$Type)

# Vẽ biểu đồ tổng hợp với facet_wrap theo Group, sắp xếp thứ tự mong muốn
ggplot(Force_ECAPPC_505010) +
  aes(x = `Hành trình`, y = `Load, tf`, colour = Type, group = Type, linetype = Type, shape = Type) +geom_line(size = 1) +
  geom_point(alpha = 1, size = 1) +
  # Vẽ khung rectangle (nền trắng, viền đen)
  geom_rect(data = rect_data, aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax),
            fill = "white", color = "black", inherit.aes = FALSE, alpha = 0.8) +
  # Vẽ đường ở vị trí cố định gần giữa
  geom_segment(data = annotation_data, aes(x = 29, xend = 33, y = y_pos, yend = y_pos, linetype = types, colour = types),
               size = 1, inherit.aes = FALSE) +
  # Vẽ nốt ở giữa đoạn đường
  geom_point(data = annotation_data, aes(x = 31, y = y_pos, shape = types, colour = types),
             size = 2, inherit.aes = FALSE) +
  # Vẽ text chú thích, căn giữa tự động
  geom_text(data = annotation_data, aes(x = 34, y = y_pos, label = types, colour = types),
            size = 7, hjust = 0, family = "Times New Roman", inherit.aes = FALSE) +  # hjust = 0.5 để căn giữa văn bản
  # Định dạng kiểu đường, hình dạng điểm, và màu sắc
  scale_linetype_manual(values = c("solid", "twodash", "dashed", "solid", "twodash", "dashed","solid", "twodash", "dashed","solid", "twodash", "dashed")) +
  scale_shape_manual(values = c(0, 19, 2, 0, 19, 2, 0, 19, 2, 0, 19, 2)) +
  scale_color_manual(values = c("darkgreen", "red", "blue", "darkgreen", "red", "blue", "darkgreen", "red", "blue", "darkgreen","red","blue")) +
  scale_x_continuous(limits = c(0, 50), breaks = seq(0, 50, by = 5)) +
  scale_y_continuous(limits = c(0, 55), breaks = seq(0, 55, by = 5)) +
  labs(x = "Hành trình (mm)", y = "Lực (tấn)", title = "Đồ thị lực khuôn ECAP PC") +
  coord_fixed(ratio = 0.75) +
  theme_bw() +
  theme(
    panel.grid.minor.x = element_blank(),
    panel.grid.minor.y = element_blank(),
    panel.grid.major.x = element_line(color = "gray", linewidth = 0.25, linetype = "dashed"),
    panel.grid.major.y = element_line(color = "gray", linewidth = 0.25, linetype = "dashed"),
    panel.border = element_blank(),
    axis.line = element_line(color = "black", linewidth = 0.5),
    axis.text = element_text(color = "black", size = 20),
    axis.title = element_text(color = "black", size = 20),
    plot.title = element_text(family = "Times New Roman Bold", size = 20, face = "bold", hjust = 0.5),
    axis.title.y = element_text(family = "Times New Roman Bold", size = 20, face = "bold", vjust = 2, margin = margin(r = 5)),
    axis.title.x = element_text(family = "Times New Roman Bold", size = 20, face = "bold", vjust = -2),
    axis.text.y = element_text(family = "Times New Roman", size = 20, face = "plain"),
    axis.text.x = element_text(family = "Times New Roman", size = 20, face = "plain"),
    strip.text.x = element_text(family = "Times New Roman Bold", size = 20, face = "bold"))+
  theme(legend.position = "none",           #Xoá legend
        plot.title = element_blank())+
  facet_wrap(vars(factor(`Group`, levels = c("Φ75", "Φ90", "Φ100", "Φ120"))))

Đồ thị lực Φ75, 1d;1,5d;2d

# Đồ thị lực ECAP PC
#1. ECAPPC_50x50x10_F75


library(readxl)
Force_ECAPPC_505010_F75 <- read_excel("~/0.Caohoc_Phuong/3.Ky2_1/6.BDDManhLiet/Force_ECAPPC_505010.xlsx", 
    sheet = "LucECAPPC_505010_F75", col_types = c("numeric", "numeric", "numeric", "text"))
head(Force_ECAPPC_505010_F75)
## # A tibble: 6 × 4
##   `Distance, mm` `Load, tf` `Hành trình` Type   
##            <dbl>      <dbl>        <dbl> <chr>  
## 1           49.2    0.0116         0     Φ75; 1d
## 2           49.0    0.00491        0.188 Φ75; 1d
## 3           48.6    0.370          0.542 Φ75; 1d
## 4           48.3    0.892          0.880 Φ75; 1d
## 5           48.0    1.17           1.15  Φ75; 1d
## 6           47.8    1.49           1.36  Φ75; 1d
library(dplyr)

ggplot(Force_ECAPPC_505010_F75) +
  aes(x = `Hành trình`, y = `Load, tf`, colour = Type, group = Type) +
  geom_line() +
  geom_point(aes(shape = Type, color = Type, group = Type, x = `Hành trình`, y = `Load, tf`), alpha = 1, size = 1.5) +
  scale_color_hue(direction = 1) +
  scale_x_continuous(limits = c(0, 50), breaks = seq(0, 50, by = 5)) +
  scale_y_continuous(limits = c(0, 55), breaks = seq(0, 55, by = 5)) +
  labs(x = "Hành trình (mm)", y = "Lực (tấn)", title = "Đồ thị lực khuôn ghép côn") +
  coord_fixed(ratio = 0.75) + # Tỷ lệ chiều dài trục y/x
  theme_bw() +
  theme(
    panel.grid.minor.x = element_blank(),  # Loại bỏ đường lưới dọc nhỏ
    panel.grid.minor.y = element_blank(),  # Loại bỏ đường lưới dọc nhỏ
    panel.grid.major.x = element_line(color = "gray", linewidth = 0.55, linetype = "dashed"),  # Thêm đường lưới dọc nét đứt
    panel.grid.major.y = element_line(color = "gray", linewidth = 0.55, linetype = "dashed"),  # Thêm đường lưới ngang nét đứt
    panel.border = element_blank(),  # Loại bỏ viền 4 cạnh
    axis.line = element_line(color = "black", linewidth = 0.5),  # Thêm axis lines đen mỏng chỉ cho x và y
    #panel.border = element_rect(color = "black", fill = NA, linewidth = 1),  # Thêm viền đen đậm 4 canh
    axis.text = element_text(color = "black", size = 14),  # Chữ trên trục màu đen
    axis.title = element_text(color = "black", size = 14))+   # Tiêu đề trục màu đen
  theme(plot.title = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", hjust = 0.5), #hjust là căn giữa tiêu đề
      axis.title.y = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", vjust = 2, margin = margin(r = 5)), 
      axis.title.x = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", vjust = -2), 
      axis.text.y = element_text(family = "Times New Roman", size = 14L, face = "plain"),   # Chữ trên trục đen không đậm
      axis.text.x = element_text(family = "Times New Roman", size = 14L, face = "plain"))+  # Chữ trên trục đen không đậm
  theme(legend.title = element_text(family = "Times New Roman", size = 14L),
        legend.text = element_text(family = "Times New Roman", size = 14L))+
  theme(
    legend.position = c(0.85, 0.3),  # Đặt tọa độ legend trong khung đồ thị
    legend.background = element_rect(color = "black", fill = "white"), # Thêm nền và viền
    legend.key.size = unit(1.5, "lines"),
    legend.title.align = 0.5,
    legend.title = element_blank(),
    plot.title = element_blank()) # Ẩn tiêu đề đồ thị

# Cần xem giá trị thì:
#DT1 =ggplot(Force_ECAPPC_F100L15)
#ggplotly(DT1)

Đồ thị lực Φ90, 1d;1,5d;2d

# Đồ thị lực ECAP PC
#1. ECAPPC_50x50x10_F90


library(readxl)
Force_ECAPPC_505010_F90 <- read_excel("~/0.Caohoc_Phuong/3.Ky2_1/6.BDDManhLiet/Force_ECAPPC_505010.xlsx", 
    sheet = "LucECAPPC_505010_F90", col_types = c("numeric", "numeric", "numeric", "text"))
head(Force_ECAPPC_505010_F90)
## # A tibble: 6 × 4
##   `Distance, mm` `Load, tf` `Hành trình` Type   
##            <dbl>      <dbl>        <dbl> <chr>  
## 1           49      0.00136        0     Φ90; 1d
## 2           48.4    0.300          0.567 Φ90; 1d
## 3           48.4    0.872          0.632 Φ90; 1d
## 4           48.1    1.21           0.901 Φ90; 1d
## 5           47.9    1.73           1.14  Φ90; 1d
## 6           47.6    2.07           1.37  Φ90; 1d
library(dplyr)

ggplot(Force_ECAPPC_505010_F90) +
  aes(x = `Hành trình`, y = `Load, tf`, colour = Type, group = Type) +
  geom_line() +
  geom_point(aes(shape = Type, color = Type, group = Type, x = `Hành trình`, y = `Load, tf`), alpha = 1, size = 1.5) +
  scale_color_hue(direction = 1) +
  scale_x_continuous(limits = c(0, 50), breaks = seq(0, 50, by = 5)) +
  scale_y_continuous(limits = c(0, 55), breaks = seq(0, 55, by = 5)) +
  labs(x = "Hành trình (mm)", y = "Lực (tấn)", title = "Đồ thị lực khuôn ghép côn") +
  coord_fixed(ratio = 0.75) + # Tỷ lệ chiều dài trục y/x
  theme_bw() +
  theme(
    panel.grid.minor.x = element_blank(),  # Loại bỏ đường lưới dọc nhỏ
    panel.grid.minor.y = element_blank(),  # Loại bỏ đường lưới dọc nhỏ
    panel.grid.major.x = element_line(color = "gray", linewidth = 0.55, linetype = "dashed"),  # Thêm đường lưới dọc nét đứt
    panel.grid.major.y = element_line(color = "gray", linewidth = 0.55, linetype = "dashed"),  # Thêm đường lưới ngang nét đứt
    panel.border = element_blank(),  # Loại bỏ viền 4 cạnh
    axis.line = element_line(color = "black", linewidth = 0.5),  # Thêm axis lines đen mỏng chỉ cho x và y
    #panel.border = element_rect(color = "black", fill = NA, linewidth = 1),  # Thêm viền đen đậm 4 canh
    axis.text = element_text(color = "black", size = 14),  # Chữ trên trục màu đen
    axis.title = element_text(color = "black", size = 14))+   # Tiêu đề trục màu đen
  theme(plot.title = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", hjust = 0.5), #hjust là căn giữa tiêu đề
      axis.title.y = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", vjust = 2, margin = margin(r = 5)), 
      axis.title.x = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", vjust = -2), 
      axis.text.y = element_text(family = "Times New Roman", size = 14L, face = "plain"),   # Chữ trên trục đen không đậm
      axis.text.x = element_text(family = "Times New Roman", size = 14L, face = "plain"))+  # Chữ trên trục đen không đậm
  theme(legend.title = element_text(family = "Times New Roman", size = 14L),
        legend.text = element_text(family = "Times New Roman", size = 14L))+
  theme(
    legend.position = c(0.85, 0.3),  # Đặt tọa độ legend trong khung đồ thị
    legend.background = element_rect(color = "black", fill = "white"), # Thêm nền và viền
    legend.key.size = unit(1.5, "lines"),
    legend.title.align = 0.5,
    legend.title = element_blank(),
    plot.title = element_blank()) # Ẩn tiêu đề đồ thị
## Warning: Removed 3 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 3 rows containing missing values or values outside the scale range
## (`geom_point()`).

# Cần xem giá trị thì:
#DT1 =ggplot(Force_ECAPPC_F100L15)
#ggplotly(DT1)

Đồ thị lực Φ100, 1d;1,5d;2d

# Đồ thị lực ECAP PC
#1. ECAPPC_50x50x10_F100


library(readxl)
Force_ECAPPC_505010_F100 <- read_excel("~/0.Caohoc_Phuong/3.Ky2_1/6.BDDManhLiet/Force_ECAPPC_505010.xlsx", 
    sheet = "LucECAPPC_505010_F100", col_types = c("numeric", "numeric", "numeric", "text"))
head(Force_ECAPPC_505010_F100)
## # A tibble: 6 × 4
##   `Distance, mm` `Load, tf` `Hành trình` Type    
##            <dbl>      <dbl>        <dbl> <chr>   
## 1           49.1      0            0     Φ100; 1d
## 2           48.8      0.789        0.311 Φ100; 1d
## 3           48.5      1.06         0.649 Φ100; 1d
## 4           48.1      1.49         0.969 Φ100; 1d
## 5           47.9      1.89         1.20  Φ100; 1d
## 6           47.7      2.63         1.44  Φ100; 1d
library(dplyr)

ggplot(Force_ECAPPC_505010_F100) +
  aes(x = `Hành trình`, y = `Load, tf`, colour = Type, group = Type) +
  geom_line() +
  geom_point(aes(shape = Type, color = Type, group = Type, x = `Hành trình`, y = `Load, tf`), alpha = 1, size = 1.5) +
  scale_color_hue(direction = 1) +
  scale_x_continuous(limits = c(0, 50), breaks = seq(0, 50, by = 5)) +
  scale_y_continuous(limits = c(0, 55), breaks = seq(0, 55, by = 5)) +
  labs(x = "Hành trình (mm)", y = "Lực (tấn)", title = "Đồ thị lực khuôn ghép côn") +
  coord_fixed(ratio = 0.75) + # Tỷ lệ chiều dài trục y/x
  theme_bw() +
  theme(
    panel.grid.minor.x = element_blank(),  # Loại bỏ đường lưới dọc nhỏ
    panel.grid.minor.y = element_blank(),  # Loại bỏ đường lưới dọc nhỏ
    panel.grid.major.x = element_line(color = "gray", linewidth = 0.55, linetype = "dashed"),  # Thêm đường lưới dọc nét đứt
    panel.grid.major.y = element_line(color = "gray", linewidth = 0.55, linetype = "dashed"),  # Thêm đường lưới ngang nét đứt
    panel.border = element_blank(),  # Loại bỏ viền 4 cạnh
    axis.line = element_line(color = "black", linewidth = 0.5),  # Thêm axis lines đen mỏng chỉ cho x và y
    #panel.border = element_rect(color = "black", fill = NA, linewidth = 1),  # Thêm viền đen đậm 4 canh
    axis.text = element_text(color = "black", size = 14),  # Chữ trên trục màu đen
    axis.title = element_text(color = "black", size = 14))+   # Tiêu đề trục màu đen
  theme(plot.title = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", hjust = 0.5), #hjust là căn giữa tiêu đề
      axis.title.y = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", vjust = 2, margin = margin(r = 5)), 
      axis.title.x = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", vjust = -2), 
      axis.text.y = element_text(family = "Times New Roman", size = 14L, face = "plain"),   # Chữ trên trục đen không đậm
      axis.text.x = element_text(family = "Times New Roman", size = 14L, face = "plain"))+  # Chữ trên trục đen không đậm
  theme(legend.title = element_text(family = "Times New Roman", size = 14L),
        legend.text = element_text(family = "Times New Roman", size = 14L))+
  theme(
    legend.position = c(0.85, 0.3),  # Đặt tọa độ legend trong khung đồ thị
    legend.background = element_rect(color = "black", fill = "white"), # Thêm nền và viền
    legend.key.size = unit(1.5, "lines"),
    legend.title.align = 0.5,
    legend.title = element_blank(),
    plot.title = element_blank()) # Ẩn tiêu đề đồ thị
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

# Cần xem giá trị thì:
#DT1 =ggplot(Force_ECAPPC_F100L15)
#ggplotly(DT1)

Đồ thị lực Φ120, 1d;1,5d;2d

# Đồ thị lực ECAP PC
#1. ECAPPC_50x50x10_F120


library(readxl)
Force_ECAPPC_505010_F120 <- read_excel("~/0.Caohoc_Phuong/3.Ky2_1/6.BDDManhLiet/Force_ECAPPC_505010.xlsx", 
    sheet = "LucECAPPC_505010_F120", col_types = c("numeric", "numeric", "numeric", "text"))
head(Force_ECAPPC_505010_F120)
## # A tibble: 6 × 4
##   `Distance, mm` `Load, tf` `Hành trình` Type    
##            <dbl>      <dbl>        <dbl> <chr>   
## 1           49.2      0            0     Φ120; 1d
## 2           48.6      0.832        0.526 Φ120; 1d
## 3           48.2      1.30         0.943 Φ120; 1d
## 4           47.9      1.79         1.27  Φ120; 1d
## 5           47.6      2.47         1.56  Φ120; 1d
## 6           47.3      3.37         1.84  Φ120; 1d
library(dplyr)

ggplot(Force_ECAPPC_505010_F120) +
  aes(x = `Hành trình`, y = `Load, tf`, colour = Type, group = Type) +
  geom_line() +
  geom_point(aes(shape = Type, color = Type, group = Type, x = `Hành trình`, y = `Load, tf`), alpha = 1, size = 1.5) +
  scale_color_hue(direction = 1) +
  scale_x_continuous(limits = c(0, 50), breaks = seq(0, 50, by = 5)) +
  scale_y_continuous(limits = c(0, 55), breaks = seq(0, 55, by = 5)) +
  labs(x = "Hành trình (mm)", y = "Lực (tấn)", title = "Đồ thị lực khuôn ghép côn") +
  coord_fixed(ratio = 0.75) + # Tỷ lệ chiều dài trục y/x
  theme_bw() +
  theme(
    panel.grid.minor.x = element_blank(),  # Loại bỏ đường lưới dọc nhỏ
    panel.grid.minor.y = element_blank(),  # Loại bỏ đường lưới dọc nhỏ
    panel.grid.major.x = element_line(color = "gray", linewidth = 0.55, linetype = "dashed"),  # Thêm đường lưới dọc nét đứt
    panel.grid.major.y = element_line(color = "gray", linewidth = 0.55, linetype = "dashed"),  # Thêm đường lưới ngang nét đứt
    panel.border = element_blank(),  # Loại bỏ viền 4 cạnh
    axis.line = element_line(color = "black", linewidth = 0.5),  # Thêm axis lines đen mỏng chỉ cho x và y
    #panel.border = element_rect(color = "black", fill = NA, linewidth = 1),  # Thêm viền đen đậm 4 canh
    axis.text = element_text(color = "black", size = 14),  # Chữ trên trục màu đen
    axis.title = element_text(color = "black", size = 14))+   # Tiêu đề trục màu đen
  theme(plot.title = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", hjust = 0.5), #hjust là căn giữa tiêu đề
      axis.title.y = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", vjust = 2, margin = margin(r = 5)), 
      axis.title.x = element_text(family = "Times New Roman Bold", size = 14L, face = "bold", vjust = -2), 
      axis.text.y = element_text(family = "Times New Roman", size = 14L, face = "plain"),   # Chữ trên trục đen không đậm
      axis.text.x = element_text(family = "Times New Roman", size = 14L, face = "plain"))+  # Chữ trên trục đen không đậm
  theme(legend.title = element_text(family = "Times New Roman", size = 14L),
        legend.text = element_text(family = "Times New Roman", size = 14L))+
  theme(
    legend.position = c(0.85, 0.3),  # Đặt tọa độ legend trong khung đồ thị
    legend.background = element_rect(color = "black", fill = "white"), # Thêm nền và viền
    legend.key.size = unit(1.5, "lines"),
    legend.title.align = 0.5,
    legend.title = element_blank(),
    plot.title = element_blank()) # Ẩn tiêu đề đồ thị

# Cần xem giá trị thì:
#DT1 =ggplot(Force_ECAPPC_F100L15)
#ggplotly(DT1)