[英]Labeling specific points of a scatter plot
I want to plot a scatter plot with only specific labels that meet my criteria 我想绘制仅包含符合我的条件的特定标签的散点图
I have a dataframe df that looks like 我有一个看起来像的数据框df
In.Deg `Out.Deg Name
34 38 ABC
56 45 Dummy
53 54 Another_Dummy
I only want values which meet the criteria ( In.Deg > 50 & Out.Deg>50) to be labeled in the plot. 我只希望在图中标记符合条件的值(In.Deg> 50&Out.Deg> 50)。
I want only want Another_Dummy to be displayed . 我只想显示Another_Dummy。 I do not want the other names to be displayed as labels while plotting.
我不希望在绘图时将其他名称显示为标签。
Appreciate the help 感谢帮助
## read in your data
d <- read.table(header = TRUE, text = "In.Deg Out.Deg Name
34 38 ABC
56 45 Dummy
53 54 Another_Dummy ")
## subset and plot with label
s <- subset(d, In.Deg > 50 & Out.Deg > 50)
with(d, plot(In.Deg, Out.Deg))
text(s[,1:2], labels = s[,3], pos = 1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.