usim <- read_csv("data/usim_umid.csv") %>%
  pivot_longer(usim_o:umid_a, names_to = 'type', values_to = 'correlation') %>%
  mutate(
    embedding = case_when(
      str_detect(type, "o") ~ "Original",
      str_detect(type, "a") ~ "Makesense"
    ),
    type = str_replace(type, "_(o|a)", ""),
    type = factor(type, levels = c("usim", "umid")),
    correlation = case_when(
      type == "umid" ~ -correlation,
      TRUE ~ correlation
    )
  )

usim %>%
  ggplot(aes(layer, correlation, color = embedding, shape = embedding)) +
  geom_point(size = 4) +
  geom_line(size = 1) +
  facet_wrap(~type, scales = "free_y") +
  # scale_y_continuous(limits = c(0, 0.6)) +
  scale_x_continuous(breaks = 0:12, minor_breaks = NULL) +
  scale_color_manual(values = c("#2978b5", "#f7a440")) +
  theme_bw(base_size = 20, base_family = "Times") +
  theme(
    legend.position = "top",
    plot.margin = margin(0.1, 0.2, 0.1, 0.1, "cm"),
    panel.background = element_rect(fill = "transparent"), # bg of the panel
    plot.background = element_rect(fill = "transparent", color = NA)
  ) +
  labs(
    x = "Layer",
    y = "Spearman's R",
    color = "Representation",
    shape = "Representation"
    # linetype = "Judgment"
  ) 