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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:29:18+00:00 2026-05-21T00:29:18+00:00

I’m working on a project where I have multiple response variables and want to

  • 0

I’m working on a project where I have multiple response variables and want to show ordered caterpillar plots. This is fairly straightforward with the base R plotting capabilities

#generate random data frame
set.seed(42)
my_df<-data.frame(x=rnorm(100), y=runif(100,-2,2), z=rpois(100, 10))

#3 panels of plots
par(mfrow=c(1,3))

#note the abline to show an axis at y=0
sapply(c("x", "y", "z"), function(i){ plot(sort(my_df[[i]])); abline(0,0)})

But I am at a loss as to how to do this with ggplot2. To put together the three panels, I know I have to melt the data frame, but then…how does one do the ordering by variable and plotting with a 0 axis later? All I have so far is…

melt_df<-melt(my_df)

qplot(1:100, value, data=melt_df, geom="point",facets=~variable)+theme_bw(base_size=16)
  • 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-21T00:29:19+00:00Added an answer on May 21, 2026 at 12:29 am

    Building off jebyrnes answer – you can set the y-axis to have free scales as an argument in facet_wrap. We can add a horizontal line with geom_hline():

    ggplot(melt_df, aes(1:100, value)) + geom_point() + 
        facet_wrap(~ variable, ncol = 3, scales = "free_y") +
        geom_hline(aes(intercept = 0), linetype = 2) +
        theme_bw(base_size = 16)
    

    You can get equivalent results by using stat_qq() and avoid the sorting with ddply beforehand. The difference is that we only need to pass in the sample argument to aes:

    ggplot(melt_df, aes(sample = value)) + geom_point(stat = "qq") + 
        facet_wrap(~ variable, ncol = 3, scales = "free_y") +
        geom_hline(aes(intercept = 0), linetype = 2) +
        theme_bw(base_size = 16)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.