我试图围绕如何以一种方式可视化一堆相对频率的问题,这种方式可以很容易地看出它们相互之间的比较。在分配方面,差异并不大,当然,我也考虑一些值得展示的东西。我设法创建了一个相对简单的点图,但是,我认为它看起来不够好。
代码很简单(虽然就视觉调整而言尚未完成),我想:
library(ggplot2)
copuladeletion <- read.table(text = "Type Distribution Family
NP 0.39344 Austronesian
NP 0.30232 Mon-Khmer
NP 0.3125 Tai-Kadai
NP 0.29230 Sinitic
NP 0.26785 Other
AdjP 0.44262 Austronesian
AdjP 0.53488 Mon-Khmer
AdjP 0.625 Tai-Kadai
AdjP 0.55384 Sinitic
AdjP 0.58928 Other
AdvP 0.03278 Austronesian
AdvP 0.00000 Mon-Khmer
AdvP 0.00000 Tai-Kadai
AdvP 0.04615 Sinitic
AdvP 0.07142 Other
EX 0.01639 Austronesian
EX 0.02325 Mon-Khmer
EX 0.00000 Tai-Kadai
EX 0.03076 Sinitic
EX 0.01785 Other
Clause 0.08196 Austronesian
Clause 0.02325 Mon-Khmer
Clause 0.0625 Tai-Kadai
Clause 0.03076 Sinitic
Clause 0.05357 Other
Other 0.01639 Austronesian
Other 0.11627 Mon-Khmer
Other 0.00000 Tai-Kadai
Other 0.04615 Sinitic
Other 0.00000 Other", header = TRUE)
ggplot(copuladeletion) + geom_point(aes(Distribution, Type, colour=Family,size=1))
产生以下图像:
所以,我的问题是:
您认为此可视化效果如何吗? 这些数据的简单点图是否有更好的选择?
非常感谢你!
答案 0 :(得分:3)
也许只是你的条形图上的另一个镜头:
library(ggplot2)
copuladeletion <- read.table(text=txt, header=TRUE)
gg <- ggplot(copuladeletion)
gg <- gg + geom_point(aes(Distribution, Type, colour=Family),
shape="|", size=10)
gg <- gg + scale_x_continuous(breaks=seq(0, 0.7, 0.1))
gg <- gg + scale_y_discrete(expand=c(0,0))
gg <- gg + scale_colour_brewer(name="", palette="Set1")
gg <- gg + facet_wrap(~Type, ncol=1, scales="free_y")
gg <- gg + guides(colour=guide_legend(override.aes=list(shape=15, size=3)))
gg <- gg + labs(x=NULL, y=NULL, title="Family Distribution by Type")
gg <- gg + theme_bw()
gg <- gg + theme(panel.grid.major=element_blank())
gg <- gg + theme(panel.grid.minor=element_blank())
gg <- gg + theme(strip.background=element_blank())
gg <- gg + theme(strip.text=element_blank())
gg <- gg + theme(axis.ticks=element_blank())
gg <- gg + theme(legend.key=element_blank())
gg <- gg + theme(legend.position="bottom")
gg
为了稍微补偿重叠(正如Roman已经指出了cpl次),你可以使用正确的线与hack-y点:
gg <- ggplot(copuladeletion)
gg <- gg + geom_segment(aes(x=Distribution, xend=Distribution,
y=0, yend=1, colour=Family), size=0.25)
gg <- gg + scale_x_continuous(breaks=seq(0, 0.7, 0.1))
gg <- gg + scale_y_discrete(expand=c(0,0))
gg <- gg + scale_colour_brewer(name="", palette="Set1")
gg <- gg + facet_wrap(~Type, ncol=1, scales="free_y", switch="y")
gg <- gg + labs(x=NULL, y=NULL, title="Family Distribution by Type")
gg <- gg + guides(colour=guide_legend(override.aes=list(shape=15, size=3)))
gg <- gg + theme_bw()
gg <- gg + theme(panel.border=element_rect(color="#2b2b2b", size=0.15))
gg <- gg + theme(panel.grid.major=element_blank())
gg <- gg + theme(panel.grid.minor=element_blank())
gg <- gg + theme(strip.background=element_blank())
gg <- gg + theme(strip.text.y=element_text(angle=180))
gg <- gg + theme(axis.ticks=element_blank())
gg <- gg + theme(legend.key=element_blank())
gg <- gg + theme(legend.position="bottom")
gg
您也可以添加美学来映射linetype
(并根据需要添加hjust
个y标签)。这些细线有点难以阅读(因此也可以随意调整size
),但我认为条形图对这些数据非常有效。您可能希望缩小&#34;单独的情节中的EX
条如果你需要(我不知道这些数据真正想说的是什么: - )
答案 1 :(得分:1)