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 6939735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:39:35+00:00 2026-05-27T12:39:35+00:00

In a ggplot boxplot , it is easy to use jitter to add the

  • 0

In a ggplot boxplot, it is easy to use jitter to add the raw data points with varying degrees of jitter. With zero jitter the following code

dat <- data.frame(group=c('a', 'b', 'c'), values = runif(90))

ggplot(dat, aes(group, values)) + 
geom_boxplot(outlier.size = 0) + 
geom_jitter(position=position_jitter(width=0), aes(colour=group), alpha=0.7) + 
ylim(0, 1) + stat_summary(fun.y=mean, shape=3, col='red', geom='point') +
opts(legend.position = "right") + ylab("values") + xlab("group")

produces the plot below.

Is it possible to use zero jitter but add an offset such that the points are in a line but shifted left by 25% of the box width? I tried geom_point with dodge but this generated a jitter.enter image description here

  • 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-27T12:39:36+00:00Added an answer on May 27, 2026 at 12:39 pm

    If we convert group to numeric and then add an offset, you seem to get your desired output. There is probably a more effective / efficient way, but give this a whirl:

    ggplot(dat, aes(group, values)) + 
      geom_boxplot(outlier.size = 0) + 
      geom_point(aes(x = as.numeric(group) + .25, colour=group), alpha=0.7) + 
      ylim(0, 1) + stat_summary(fun.y=mean, shape=3, col='red', geom='point') +
      opts(legend.position = "right") + ylab("values") + xlab("group")
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following R code: ggplot(data=curve,aes(x = expected, y=result/games)) + geom_point(aes(x=-expected, colour=games)) + stat_function(fun=funx,
I am making a dotplot using ggplot with the code and data that is
I have a nearly-boxplot like jitter-plot: dt <- rbind(se,cb,cb.se) qplot(ds, size, data=dt, geom="jitter", colour=root,
Question I'd like to use ggplot's geom_boxplot and use my own data columns for
library(ggplot2) This code produces a nice looking plot: qplot(cty, hwy, data = mpg, colour
I'm fairly new to ggplot. I have made a bumpplot using code posted below.
I am graphing some data with ggplot. However, I don't understand the error I'm
I know that after I create a ggplot graph I can use theme_get() to
I am plotting a dataset using the following: plot = ggplot(transData, aes(x=Time, y=Value)) +
Frequently, I use functions to shape or numerically alter data that I'm passing to

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.