srikantrao
srikantrao

Reputation: 198

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

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.

I want only want Another_Dummy to be displayed . I do not want the other names to be displayed as labels while plotting.

Appreciate the help

Upvotes: 1

Views: 7130

Answers (1)

Rich Scriven
Rich Scriven

Reputation: 99331

## 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)

enter image description here

Upvotes: 4

Related Questions