我有一个如下所示的数据框:
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
我的范围是制作分类变量Taxation
和Orientation
的双向散点图,其中它将用子弹显示每种可能性的数量,每个项目符号都标有各机构的原籍国。它有帮助,我想重现像这样的图表:
请注意,此图表很好地显示了一个大的“框”,表示不同组合产生的案例数量。
答案 0 :(得分:1)
这是一个想法,但是没有任何要点,因为我无法找到一种将点和文字放在一起的方法。使用包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()