可视化两个或多个重叠的数据点(ggplot R) [英] Visualizing two or more data points where they overlap (ggplot R)

查看:48
本文介绍了可视化两个或多个重叠的数据点(ggplot R)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个散点图,上面有颜色编码的数据点.当两个或多个数据点重叠时,仅显示一种颜色(以图例中的第一个为准).这些数据点中的每一个都代表一个项目,我需要显示哪些项目落在秤的每个点上.我正在使用R(v.3.3.1).根据我如何显示散点图上每个点都有多个项目,有人会提出任何建议吗?提前致谢.

  pdf('pedplot.pdf',高度= 6,宽度= 10)p3<-ggplot(data = e4,aes(x = e4 $ domain,y = e4 $ ped))+ geom_point(aes(color =e4 $ Database_acronym),大小= 3,形状= 17)+实验室(x =域",y =每个域中元素的比例",颜色=数据来源)+主题(axis.text.x = element_text(角度= 90,高度= 1))p3 dev.off(); 

解决方案

在上述

I have a scatterplot that has colour-coded data points. When two or more of the data points overlap only one of the colours is shown (whichever is first in the legend). Each of these data points represents an item and I need to show which items fall at each point on the scale. I'm using R (v.3.3.1). Would anyone have any suggestions as per how I could show that there are multiple items at each point on the scatterplot? Thanks in advance.

pdf('pedplot.pdf', height = 6, width = 10)
p3 <- ggplot(data=e4, aes(x=e4$domain, y=e4$ped)) + geom_point(aes(color = 
    e4$Database_acronym), size = 3, shape = 17) + 
    labs(x = "Domains", y = "Proportion of Elements per Domain", color = "Data 
    Sources") +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) 
p3 dev.off();

解决方案

Separately from or in addition to jittering as mentioned here, you could also consider making the points partially transparent:

linecolors <- c("#714C02", "#01587A", "#024E37")
fillcolors <- c("#9D6C06", "#077DAA", "#026D4E")

# partially transparent points by setting `alpha = 0.5`
ggplot(mpg, aes(displ, cty, colour = drv, fill = drv)) +
  geom_point(position=position_jitter(h=0.1, w=0.1),
             shape = 21, alpha = 0.5, size = 3) +
  scale_color_manual(values=linecolors) +
  scale_fill_manual(values=fillcolors) +
  theme_bw()

这篇关于可视化两个或多个重叠的数据点(ggplot R)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆