如何给剧情添加标签

如何给剧情添加标签

本文介绍了如何给剧情添加标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法给剧情中的每个点添加标签?我在一个图像编辑器上做了这个,只是为了传达这个想法:。



最初的一个产生于:

qplot(pcomments,gcomments,data = topbtw,color = username)



解决方案

为了跟进Andrie的优秀答案,我经常使用两种方法为如果我需要突出显示特定数据,则在图上的点的子集。两者都在下面进行了演示:

$ $ $ $ $ $ $ $ c $ dat $ data.frame(x = rnorm(10),y = rnorm(10) ,label = letters [1:10])

#创建要标记的数据子集。在这里,我们标记点a -e
labeled.dat< -dat [dat $ label%in%letters [1:5],]

ggplot(dat,aes(x,y ))+ geom_point()+
geom_text(data = labeled.dat,aes(x,y,label = label),hjust = 2)
$ b $#或者为每个图层添加一个单独的图层点你想要标签。
ggplot(dat,aes(x,y))+ geom_point()+
geom_text(data = dat [dat $ label ==c,],aes(x,y,label = label ),hjust = 2)+
geom_text(data = dat [dat $ label ==g,],aes(x,y,label = label),hjust = 2)


Is there a way to add labels to each point in a plot? I did this on an image editor just to convey the idea: 1.

The original one was generated with:

qplot(pcomments, gcomments , data = topbtw, colour = username)

解决方案

To follow up on Andrie's excellent answer, I frequently employ two methods to add labels to a subset of points on a plot if I need to highlight specific data. Both are demonstrated below:

dat <- data.frame(x = rnorm(10), y = rnorm(10), label = letters[1:10])

#Create a subset of data that you want to label. Here we label points a - e
labeled.dat <- dat[dat$label %in% letters[1:5] ,]

ggplot(dat, aes(x,y)) + geom_point() +
  geom_text(data = labeled.dat, aes(x,y, label = label), hjust = 2)

#Or add a separate layer for each point you want to label.
ggplot(dat, aes(x,y)) + geom_point() +
  geom_text(data = dat[dat$label == "c" ,], aes(x,y, label = label), hjust = 2) +
  geom_text(data = dat[dat$label == "g" ,], aes(x,y, label = label), hjust = 2)

这篇关于如何给剧情添加标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 05:30