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

  • Home
  • SEARCH
  • 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 9015343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:43:43+00:00 2026-06-16T03:43:43+00:00

I am working on data presentation and i need to plot boxplot with stacked

  • 0

I am working on data presentation and i need to plot boxplot with stacked barplot in parallel.

enter image description here

With colored in different shade colors with proportion of points covering area. How can i plot it?

  • 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-16T03:43:44+00:00Added an answer on June 16, 2026 at 3:43 am

    Here a generic solution that you can use to add parallel percent box to a lattice bowplot. It computes the exact percent descrbing parts of boxplot (whisker and main part).

    The solution is based on the grid package. Viewport manipulation is easier with lattice than ggplot2, that’s why I choose a bwplot.

    I generate some sample data:

    df <- data.frame(cond = factor( rep(c("A"), each=200) ), 
                     rating = c(rnorm(200),rnorm(200, mean=.8)))
    
    library(lattice)
    bwplot(cond ~ rating, data=df,gp=gpar(fill='blue'),
           par.settings = list( box.umbrella=list(col= c( "red")), 
                                box.dot=list(col= c("green")), 
                                box.rectangle = list(fill= c( "blue"),alpha=0.6)))
    

    I catch the main viewport

    downViewport("plot_01.panel.1.1.vp")
    

    Then I store the dimensions of whiskers and positions of extremities boxplot positions.

    segs <- grid.get('segments',grep=T)
    cap.segs <- grid.get('cap.segments',grep=T)
    

    The function drawBox , draw a rectangle with the text in percent. I Call it 3 times for each box.

    drawbox <- function(x0 = segs$x0[1] , col ='red',
                        width.vp = segs$x0[2] - segs$x0[1]){
      vpd <- viewport(
                x = x0 ,
                y = cap.segs$y1[2] + unit(0.5,'native'),
                width  = width.vp,
                height = unit(2,'cm'),
                just   = c('left','bottom'),
                name   = 'vpd')
      pushViewport(vpd)
        grid.rect(gp=(gpar(fill=col)))
        # The compute of percent is a little bit tricky due we can't apply '/'
        value <- as.numeric(convertUnit(width.vp,'native'))
        value <- value/as.numeric(convertUnit(cap.segs$x0[2]- cap.segs$x0[1],'native'))
        grid.text(label = paste(round(value*100),'%',sep='') , gp= gpar(cex=3))
      upViewport(1)
    }
    

    The function drawbox is called 3 times:

    drawbox()
    drawbox(col='yellow',width=segs$x0[1] - cap.segs$x0[1], x0= cap.segs$x0[1])
    drawbox(col='green',width.vp= cap.segs$x0[2]- segs$x0[2],x0 = segs$x0[2])
    

    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'm working with data processing and want to generate PowerPoint or OpenOffice Impress presentation
Need help getting Ember-Data working with Zend Rest. At first, I'm familiar with Zend
I am working with data.frames that have very similar names (df1, df2,.. df7). Because
The following is the data I am working on: __DATA__ Node 1: 98 debug
im working with core-data for the first time, and my app is handling a
I'm working with airline data, so I have a query like this SELECT Invoices.PNR,
I am working with a data view web part in SPD 2010. My xml
I'm working on extracting data from a SQL Server database with a latin_1 character
I'm working on a data distribution application which receives data from a source and
I'm working with XML data from an application where we get XML like this:

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.