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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:06:46+00:00 2026-06-12T01:06:46+00:00

I often have numeric values for faceting. I wish to provide sufficient information to

  • 0

I often have numeric values for faceting.
I wish to provide sufficient information to interpret these faceting values in a supplemental title, similar to the axis titles.
The labeller options repeat much unnecessary text and are unusable for longer variable titles.

Any suggestions?

The default:

test<-data.frame(x=1:20, y=21:40, facet.a=rep(c(1,2),10), facet.b=rep(c(1,2), each=20))
qplot(data=test, x=x, y=y, facets=facet.b~facet.a)

enter image description here

What I would love:

enter image description here

The best I can do in ggplot:

qplot(data=test, x=x, y=y)+facet_grid(facet.b~facet.a, labeller=label_both)

enter image description here

As indicated by @Hendy, similar to:
add a secondary y axis to ggplot2 plots – make it perfect

  • 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-12T01:06:47+00:00Added an answer on June 12, 2026 at 1:06 am

    As the latest ggplot2 uses gtable internally, it is quite easy to modify a figure:

    library(ggplot2)
    test <- data.frame(x=1:20, y=21:40, 
                       facet.a=rep(c(1,2),10), 
                       facet.b=rep(c(1,2), each=20))
    p <- qplot(data=test, x=x, y=y, facets=facet.b~facet.a)
    
    # get gtable object
    z <- ggplotGrob(p)
    
    library(grid)
    library(gtable)
    # add label for right strip
    z <- gtable_add_cols(z, unit(z$widths[[7]], 'cm'), 7)
    z <- gtable_add_grob(z, 
                         list(rectGrob(gp = gpar(col = NA, fill = gray(0.5))),
                              textGrob("Variable 1", rot = -90, gp = gpar(col = gray(1)))),
                         4, 8, 6, name = paste(runif(2)))
    
    # add label for top strip
    z <- gtable_add_rows(z, unit(z$heights[[3]], 'cm'), 2)
    z <- gtable_add_grob(z, 
                         list(rectGrob(gp = gpar(col = NA, fill = gray(0.5))),
                              textGrob("Variable 2", gp = gpar(col = gray(1)))),
                         3, 4, 3, 6, name = paste(runif(2)))
    
    # add margins
    z <- gtable_add_cols(z, unit(1/8, "line"), 7)
    z <- gtable_add_rows(z, unit(1/8, "line"), 3)
    
    # draw it
    grid.newpage()
    grid.draw(z)
    

    enter image description here

    Of course, you can write a function that automatically add the strip labels. A future version of ggplot2 may have this functionality; not sure though.

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

Sidebar

Related Questions

I often have similar constructions: var t = from i in Enumerable.Range(0,5) select num(i);
I often have to sort a dictionary (consisting of keys & values) by value.
I often have a situation in my Java code when I need to set
I often have to deal with XML documents that contain namespaced elements, but doesn't
I have found that I often have to implement some sort of a scheduler
I quite often have rows of code like the following: UPDATE my_table SET name
Python and Matlab quite often have integer date representations as follows: 733828.0 733829.0 733832.0
In most programming languages you often have a namespace > files > classes >
When I have a controller, e.g. article I often have a action_view() that handles
When I am writing for example Spring Bean I often have empty element without

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.