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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:35:47+00:00 2026-06-14T07:35:47+00:00

I have a plotting question regarding boxplots (using base graphics). I have several arrays

  • 0

I have a plotting question regarding boxplots (using base graphics).

I have several arrays of data which I wish to turn into box plots and compare. The arrays reflect different experiments and what I would like to show is the base results and the percentage difference for the experiments (on one plot!). I.e. the base results on the 1st y axis and the % diff on the second y axis:

base <- array(runif(12*24*3), dim=c(12,24,3))
exp1 <- array(runif(12*24*3), dim=c(12,24,3))
exp2 <- array(runif(12*24*3), dim=c(12,24,3))
exp3 <- array(runif(12*24*3), dim=c(12,24,3))
exp4 <- array(runif(12*24*3), dim=c(12,24,3))

# calc p.diff
p.diff   <- function(mod,base)  {
                 100.0*((mod-base)/base) }

a <- p.diff(exp1,base)
b <- p.diff(exp2,base)
c <- p.diff(exp3,base)

# combine the % diff arrays
exps <- list(a,b,c)

# plot the results
boxplot(base, xlim=c(1,4), col="gray", xaxt="n", ylab="Base values", outline=FALSE)
axis(side=1, 1:4, labels=c("base","% exp1","% exp2","% exp3") )
par(new=TRUE)
boxplot(exps, col="red", ylim=c(-200,200), outline=FALSE, axes=FALSE)
axis(4)
grid()

This almost works but I don’t get the positioning of the different box plots right (if you run my example you will see what I mean). So is there a better way to control the placement of the box plots? Or a better way to produce a similar type of figure?

  • 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-06-14T07:35:48+00:00Added an answer on June 14, 2026 at 7:35 am

    Edited (1): You need to define the rigth sequences for the X axis. So that the plots don’t overlap. Just try to play with it.

    I think the labels of the X axes are not at the right place? I don’t know a more elegant way of doing it but here is a solution:

    # plot the results
    boxplot(base, xlim=c(1,4), col="gray", xaxt="n", ylab="Base values", outline=FALSE)
    axis(side=1,1,labels=('base'))
    par(new=TRUE)
    boxplot(exps, col="red", ylim=c(-200,200), outline=FALSE, axes=FALSE)
    axis(4)
    axis(side=1,1:3,labels=c("% exp1","% exp2","% exp3"))
    grid()
    

    So I added every label after creating the boxplot. First plot the base and label it, then plot exps and label it. Does it solve your problem?

    Edit: Just to be more clear, You are adding a new plot with 3 values, that is why axis(side=1,1:3,labels=c("% exp1","% exp2","% exp3")) is from 1 to 3…

    Edited (2):

    Why don’t you use multi rows in the plot and try to plot 2 graphs? Here is an example with your data:

    #divide your plottin area into 2 columns with one row.
    par(mfrow = c(1, 2))
    # plot the results
    boxplot(base, col="gray", xaxt="n", ylab="Base values", outline=FALSE,axes=FALSE)
    axis(2)
    axis(side=1,1,labels=('base'))
    segments(0,0,1,0)
    boxplot(exps,col="red", xaxt="n", ylim=c(-200,200), outline=FALSE, axes=FALSE)
    axis(4)
    axis(side=1,at=(1:3),labels=c("% exp1","% exp2","% exp3"))
    

    you can have more information about it from here

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

Sidebar

Related Questions

I'm facing a problem with plotting data using the CorePlot framework. I have integrated
I have produced 3 sets of data which are organised in numpy arrays. I'm
I have a number of graphics objects which I am plotting in a graphics
I have a 2 part question: what is the best method for plotting data
Hi I have a quick question about converting a list of data.frames into an
I have a scaling problem with XYChart plotting: my data serie ranges in float
I'm plotting a group of curves, using facet in ggplot2. I'd like to have
I have a basic (almost naive) question for plotting on top of a pandas
I have a brief question regarding the plot3 function in MatLab. Say I write
I have a question relating to plotting a cylindrical surface in Matlab. My dataset

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.