分类变量的二元散点图

Two way scatter plot of categorical variables

我有一个这样的数据框案例:

Taxation=c("Partially",  "Fully", "Partially","Exempt","Partially","Exempt", "Partially",   "Partially", "Fully",   "Fully",    "Fully", "Exempt", "Exempt", "Fully",   "Exempt",   "Exempt","Exempt")
Orientation=c("Non-Profit",  "Non-Profit/Sustainable", "Non-Profit",    "Non-Profit",   "For-Profit",   "Non-Profit/Sustainable",   "Non-Profit",   "Non-Profit/Sustainable",   "Non-Profit",   "Non-Profit",   "Non-Profit/Sustainable",   "Non-Profit",   "Non-Profit",   "Non-Profit/Sustainable",   "Non-Profit/Sustainable",   "Non-Profit",   "Non-Profit/Sustainable")
Country=c("Austria","France",   "Spain",    "Ireland",  "Greece",   "Finland",  "Belgium",  "Austria",  "Belgium",  "Slovenia", "Italy",    "France", "Belgium",    "Portugal", "Netherlands"   ,"Denmark",     "Germany")
Institute=c("Inst1", "Inst2",   "Inst3", "Inst4",   "Inst5", "Inst6",   "Inst7", "Inst8",   "Inst9",    "Inst10",   "Inst11",   "Inst12",   "Inst13",   "Inst14",   "Inst15",   "Inst16",   "Inst17")
Count=rep(1,times=17)
df<-data.frame(Taxation=Taxation, Orientation=Orientation, Country=Country, Institute=Institute,Count=Count)

根据这个数据框,我进行了以下计算:

with(df, table(Taxation, Orientation))

Taxation    For-Profit Non-Profit Non-Profit/Sustainable
  Exempt             0          4                      3
  Fully              0          2                      3
  Partially          1          3                      1

我的范围是制作分类变量 TaxationOrientation 的双向散点图,其中它将用项目符号显示每种可能性的数量,并且每个项目符号将具有标记每个机构的原籍国。它有帮助,我想重现这样的图表:

请注意,这张图表很好地显示了不同组合产生的案例数量。

这是一个想法,但是没有任何要点,因为我想不出一种将抖动点和文本放在一起的方法。使用包 ggrepel 你可以创建不重叠的文本标签,垂直线和水平线将图分成 9 个框:

  library(ggrepel)

  ggplot(df, aes(x = Taxation, y = Orientation, label = Country)) +
  geom_text_repel(size = 4, segment.color = NA) +
  theme(panel.grid.major = element_blank(),
        axis.text.y = element_text(angle = 90, hjust = .5)) +
  geom_vline(xintercept = c(1.5, 2.5)) +
  geom_hline(yintercept = c(1.5, 2.5)) +
  coord_equal()