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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:58:39+00:00 2026-05-26T02:58:39+00:00

I am trying to plot two box-plots in the same plot, each within the

  • 0

I am trying to plot two box-plots in the same plot, each within the same category.
I can generate the boxplots individually, but am stumped when I try to get them onto the same graph.

Here is what I have so far:

a<-matrix(nrow=100,ncol=3,data=runif(300,max=2))
b<-matrix(nrow=100,ncol=3,data=runif(300,max=1))
colnames(a)<-c("case 1","case 2","case 3")
colnames(b)<-c("case 1","case 2","case 3")
boxplot(cbind(a,b))

This plot results in 6 boxplots, first 3 for a, then 3 for b.

Is there a trick/simple option that I am missing that will give me
first value for a and b, then second and finally the third set of values, all plotted in such a way there are is only three ticks on the x-axis, one for each of the sets?

Any pointers greatly appreciated,

Iain

  • 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-26T02:58:40+00:00Added an answer on May 26, 2026 at 2:58 am
    boxplot(a, at = 0:2*3 + 1, xlim = c(0, 9), ylim = range(a, b), xaxt = "n")
    boxplot(b, at = 0:2*3 + 2, xaxt = "n", add = TRUE)
    axis(1, at = 0:2*3 + 1.5, labels = colnames(a), tick = TRUE)
    

    Note the ylim = range(a, b) parameter. The plot scale is determined by the first command, but if b contained values out of range of values in a (not in this case, but try to swap a and b), they would lie out of the plot. That’s why in general you should specify the ylim here.

    You can also set tick = FALSE in the axis() command, I think it is nicer.
    If you don’t like the space between the groups, use 0:2*2 instead of 0:2*3, and change the xlim appropriatelly.

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

Sidebar

Related Questions

I'm trying to plot a box within a filled.contour plot, but unfortunately, when I
I'm trying to plot two non-intersecting touching circles, but I think I'm missing something
I am trying to plot two lines series on a chart. Each line with
I'm trying to graph two types of plots in the same window (i.e. a
I have one y variable, which I am trying to plot against two related
I'm very new to python. two days. trying to get a plot working with
I'm trying to plot lines between two or more addresses in Google Maps. The
I am running into trouble trying to compare and plot two files of different
I am trying to plot two data series in an MSChart. I am using
I'm trying to make a plot with pylab/matplotlib, and I have two different sets

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.