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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:51:50+00:00 2026-06-15T20:51:50+00:00

I want to make a plot that is similar to beanplot or violin plot,

  • 0

I want to make a plot that is similar to beanplot or violin plot, but instead of the symmetric shapes, i want to plot two different distributions on the different sides of the center line. Something like figure 4 in this article [pdf]http://www.jstatsoft.org/v28/c01/paper.

I want to use the grid graphics engine in R. Any pointers will be useful. I looked at the lattice package and the histogram function in lattice package, but that is not what i want to do.

Any help/pointers are appreciated.

  • 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-15T20:51:51+00:00Added an answer on June 15, 2026 at 8:51 pm

    You can reasonably easily get the half-violin plot with fairly simple modifications to the function, panel.violin in Sarkar’s lattice package. There are four lines in that function that can be altered inside the grid.polygon call to change from “two-sided” density plotting to single sided density plotting. First require(lattice) and require(grid). Then type panel.violin. I’ll show you the “horizontal” alteration:

    require(grid)
    panel.violin2  <-  
        # snipped all the arguments and processing
    
           grid.polygon(x = c(dx.list[[i]] ), 
       # Notice I removed: ... ,rev(dx.list[[i]]) 
                   y = c(2*dy.list[[i]]    ), default.units = "native", 
       # Removed: ...  , -rev(dy.list[[i]])
                   name = trellis.grobname(identifier, type = "panel", 
                     group = group), gp = gpar(fill = col, col = border, 
                     lty = lty, lwd = lwd, alpha = alpha))
    

    Also remove it from the corresponding section in the else{ …} clause. Now you can run it with the example in help(panel.violin)

    bwplot(voice.part ~ height, singer,
           panel = function(..., box.ratio) {
               panel.violin2(..., col = "transparent",
                            varwidth = FALSE, box.ratio = box.ratio)
               panel.bwplot(..., fill = NULL, box.ratio = .1)
           } )
    

    enter image description here

    If you wanted the density on the other side, all you would need to do would be remove the dx.list[[i]] and dy.list[[i]] and leave in the rev(dx.list[[i]]) and -rev(dy.list[[i]]).

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

Sidebar

Related Questions

I want to make a contour plot of some data, but it is possible
I'm trying to make a stacked bar plot that should show how different types
I want to make a points plot with ggplot2 geom_point where a continuous variable
I want to make a subscript for the axis label of my plot plotted
I want to make a scatter plot using matplotlib. If I want to use
I want to make a plot in which unit interval on both axes to
I want to make a 3D plot for these 100 points in X,Y and
I have a huge table and I want to make a plot of lets
I have a geom_area plot that looks like this: I want to color everything
I want to make a bar plot where one of the values is much

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.