Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6088911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:02:24+00:00 2026-05-23T12:02:24+00:00

How can I add text to points rendered with geom_jittered to label them? geom_text

  • 0

How can I add text to points rendered with geom_jittered to label them? geom_text will not work because I don’t know the coordinates of the jittered dots. Could you capture the position of the jittered points so I can pass to geom_text?

My practical usage would be to plot a boxplot with the geom_jitter over it to show the data distribution and I would like to label the outliers dots or the ones that match certain condition (for example the lower 10% for the values used for color the plots).

One solution would be to capture the xy positions of the jittered plots and use it later in another layer, is that possible?

[update]

From Joran answer, a solution would be to calculate the jittered values with the jitter function from the base package, add them to a data frame and use them with geom_point. For filtering he used ddply to have a filter column (a logic vector) and use it for subsetting the data in geom_text.

He asked for a minimal dataset. I just modified his example (a unique identifier in the label colum)

dat <- data.frame(x=rep(letters[1:3],times=100),y=runif(300),
                      lab=paste('id_',1:300,sep='')) 

This is the result of joran example with my data and lowering the display of ids to the lowest 1%
boxplot with jitter dots and label in lower 1% values

And this is a modification of the code to have colors by another variable and displaying some values of this variable (the lowest 1% for each group):

library("ggplot2")
#Create some example data
dat <- data.frame(x=rep(letters[1:3],times=100),y=runif(300),
                          lab=paste('id_',1:300,sep=''),quality= rnorm(300))

#Create a copy of the data and a jittered version of the x variable
datJit <- dat
datJit$xj <- jitter(as.numeric(factor(dat$x)))

#Create an indicator variable that picks out those
# obs that are in lowest 1% by x
datJit <- ddply(datJit,.(x),.fun=function(g){
               g$grp <- g$y <= quantile(g$y,0.01);
               g$top_q <- g$qual <= quantile(g$qual,0.01);
               g})

#Create a boxplot, overlay the jittered points and
# label the bottom 1% points
ggplot(dat,aes(x=x,y=y)) +
  geom_boxplot() +
  geom_point(data=datJit,aes(x=xj,colour=quality)) +
  geom_text(data=subset(datJit,grp),aes(x=xj,label=lab)) +
  geom_text(data=subset(datJit,top_q),aes(x=xj,label=sprintf("%0.2f",quality)))

boxplot with jitter dots and label in lower 1% values

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:02:24+00:00Added an answer on May 23, 2026 at 12:02 pm

    Your question isn’t completely clear; for example, you mention labeling points at one point but also mention coloring points, so I’m not sure which you really mean, or perhaps both. A reproducible example would be very helpful. But using a little guesswork on my part, the following code does what I think you’re describing:

    #Create some example data
    dat <- data.frame(x=rep(letters[1:3],times=100),y=runif(300),
            lab=rep('label',300))
    
    #Create a copy of the data and a jittered version of the x variable
    datJit <- dat
    datJit$xj <- jitter(as.numeric(factor(dat$x)))
    
    #Create an indicator variable that picks out those 
    # obs that are in lowest 10% by x
    datJit <- ddply(datJit,.(x),.fun=function(g){
                 g$grp <- g$y <= quantile(g$y,0.1); g})
    
    #Create a boxplot, overlay the jittered points and 
    # label the bottom 10% points
    ggplot(dat,aes(x=x,y=y)) + 
        geom_boxplot() + 
        geom_point(data=datJit,aes(x=xj)) + 
        geom_text(data=subset(datJit,grp),aes(x=xj,label=lab))        
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build a form where users can add a text field
I have a problem with WPF Toolkit Chart Control. I can't add text values
If I have an empty tag: <tag/> How can I add text so that
Can i add two header text in Datagrid? My Requirement is to have two
I have a form where users can add input fields with jQuery. <input type="text"
Can we add image together with text in a picker view? Anyone please help!
How can I add &#xD; as text when using libxslt? Or, alternatively, make all
Can somebody please explain to me the difference between: Session.Add(name,txtName.text); and Session[name] = txtName.text;
I have these Views on which I add UILabels as text, The Views can
I can add and remove the last line in my dynamic form and calculate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.