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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:06:02+00:00 2026-06-05T12:06:02+00:00

With the help of @Justin on another post, I plotted simulation result with the

  • 0

With the help of @Justin on another post, I plotted simulation result with the facet_grid option in ggplot2. The post with data and answer is here: Use facet_grid option to plot column of dataframe with ggplot2

Here a copy of original sample data with added information about scale_x min and max values for each parameter type :

dat <- read.table(textConnection("P1 P2 P3 P4 R
1 2e-5 1.0 0.6 3 1
2 4e-6 1.5 0.7 1.5 2
3 6e-7 1.2 0.6 2.5 3 
4 8e-8 1.45  0.65 3.2 4
"))

scalx <- read.table(textConnection("P XMIN XMAX
1 1 10e-1 10e-10
2 2 0.5 3.0
3 3 0.0 1.5
4 4 2.0 5.0
"))

The code given by @justin for actual example plotting:

library(ggplot2)
library(reshape2)
dat.melt <- melt(dat, id.vars='R')

ggplot(dat.melt, aes(x=0, y=value)) +
    geom_boxplot() +
    geom_point(aes(colour=factor(R))) +
    facet_wrap(~variable, ncol=1, scales='free') +
    coord_flip()

But now, my project is to make a little film to show evolution of multiple simulation result, at this time with the help of code given above I obtain great graphic like this.

enter image description here

To make this possible I need to fix the value for each facet, because each parameter can range between fixed extreme values, though what those values are changes from facet to facet.

Do you know if it’s possible with facet_grid because I found recently this issue related to specifying different limits in different facets on the github ggplot2 project repository: https://github.com/hadley/ggplot2/issues/187. Is there another alternative solution to make this possible ?

  • 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-05T12:06:03+00:00Added an answer on June 5, 2026 at 12:06 pm

    Since you are wanting to expand the scales in each facet (and not restrict/contract them), it is possible. You need to reshape your scalx into a format similar to your melted dat:

    xlims <- melt(scalx, id.vars="P")
    xlims$P <- paste0("P", xlims$P)
    names(xlims)[1] <- "variable"
    

    In addition to the melt, I made the facets have the same format and variable name. This new data frame can then be given to a geom_blank layer so that it affects the limits of the scales, but does not actually draw anything:

    ggplot(dat.melt, aes(x=0, y=value)) +
        geom_boxplot() +
        geom_point(aes(colour=factor(R))) +
        geom_blank(data=xlims) +
        facet_wrap(~variable, ncol=1, scales='free') +
        coord_flip()
    

    enter image description here

    As a side note, your P4 is listed as having a minimum of 2, but actually has a data point at 1.5. This demonstrates that this approach will only expand the scales, not contract them.

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

Sidebar

Related Questions

I received fantastic help from Dave Costa and Justin Cave here (thanks again) in
Help please on how to extract data like 15,Teaching Periods 1 and 2.,Max 150.
Help, I'm trying to create a new post in my wordpress blog with custom
some help here please with (advanced) mysql. Example illustrates the issue much better. So..
I am creating a program that I will use to help my customers recover
Help me translate following block of the Haskell code. The run function produces text
Help from the SQL Gods Required Table 1 - DistinctQuotes This tables holds information
Help! I think i've gone in a bit over my head. I'm making a
Help! I'm using the ASP.Net Login control on a Login page, but the Login
Help, I can't function without Resharper . All of a sudden my Alt +

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.