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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:55:28+00:00 2026-05-31T18:55:28+00:00

My question is as follows: in R package ggplot2 – boxplots – how to

  • 0

My question is as follows: in R package ggplot2 – boxplots – how to mark the two points at the end of the whiskers (the upper and the lower) e.g with a “x” mark so ending up with a boxplot and two additional marks of “x” at the very upper end of the whisker and the other one would be at the very lower end of the lower whisker.

I have searched a lot in the internet for an answer but couldn’t find. I could only add “x” mark on the boxplot by using the stat_summary and using mean function data.

How to do the other two points?

To be on the same page please use the mtcars database of R and make boxplot of mpg as y axis and cyl as x axis. Yu will end up with 3 boxplots according to the dataframe mtcars.

According to R

The upper end defined as Q3+1.5*IQR
The lower end defined as Q1-1.5*IQR
Note: IQR = Q3 - Q1
  • 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-31T18:55:29+00:00Added an answer on May 31, 2026 at 6:55 pm

    You just need to calculate the end points of the boxplots and add them, using stat_summary. For example

    ##Load the library
    library(ggplot2)
    data(mpg)
    
    ##Create a function to calculate the points
    ##Probably a built-in function that does this
    get_tails = function(x) {
      q1 = quantile(x)[2]
      q3 = quantile(x)[4]
      iqr = q3 -q1
      upper = q3+1.5*iqr
      lower = q1-1.5*iqr
      if(length(x) == 1){return(x)} # will deal with abnormal marks at the periphery of the plot if there is one value only
      ##Trim upper and lower
      up = max(x[x < upper])
      lo = min(x[x > lower])
      return(c(lo, up))
    }
    

    Use stat_summary to add it to your plot:

    ggplot(mpg, aes(x=drv,y=hwy)) + geom_boxplot() + 
      stat_summary(geom="point", fun.y= get_tails, colour="Red")
    

    Also, your definition of the end points isn’t quite correct. See my answer to another question for a few more details.

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

Sidebar

Related Questions

This question follows on from a previous question, that has raised a further issue.
This question follows on from a previous question. However stackoverflow presents me from commenting
My question is as follows: I have given a workbook to multiple people. They
I have a django app with models as follows: A Question model An Answer
This problem follows on from a previous question . When I run the following
There is a question in my programming languages textbook that is as follows: Write
Current Version of the Question: I initialize an array $tbd_list as follows: $tbd_list =
Here's some code (full program follows later in the question): template <typename T> T
I have an existing internal data model for a Picture , as follows: package
So here's the class and the super class, question to follow: TestDraw: package project3;

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.