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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:31:02+00:00 2026-06-09T16:31:02+00:00

I wonder how to change the facet label to math formula in ggplot2 .

  • 0

I wonder how to change the facet label to math formula in ggplot2.

d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
  xlim(0, 2) + stat_binhex(na.rm = TRUE) + opts(aspect.ratio = 1)
d + facet_wrap(~ color, ncol = 4)

enter image description here

For example, I want to change facet label from D to Y[1], where 1 is subscript. Thanks in advance for your help.

I found this answer but it does not work for me. I’m using R 2.15.1 and ggplot2 0.9.1.

  • 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-09T16:31:03+00:00Added an answer on June 9, 2026 at 4:31 pm

    Perhaps somebody has changed the name of the edit-Grob function at some point. (Edit: It was removed by @hadley about 8 months ago.) There is no geditGrob but just editGrob from pkg:grid seems to work:

     d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
                  xlim(0, 2) + stat_binhex(na.rm = TRUE) + opts(aspect.ratio = 1)
    
     #Note: changes in ggplot2 functions cause this to fail from the very beginning now.
     # Frank Harrell's answer this year suggests `facet_warp` now accepts `labeller`
    
    
     d <- d + facet_wrap(~ color, ncol = 4)
     grob <- ggplotGrob(d)
     strip_elem <- grid.ls(getGrob(grob, "strip.text.x", grep=TRUE, global=TRUE))$name
    #strip.text.x.text.1535
    #strip.text.x.text.1541
    #strip.text.x.text.1547
    #strip.text.x.text.1553
    #strip.text.x.text.1559
    #strip.text.x.text.1565
    #strip.text.x.text.1571
    grob <- editGrob(grob, strip_elem[1], label=expression(Y[1]))
    grid.draw(grob)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder how to add facet titles in ggplot2 ggplot(diamonds, aes(cut)) + geom_bar() +
Is there a way to change the font size of facet labels in ggplot
I wonder how management studio generates the change table scripts each time i change
I am new to mvc and I wonder how I can change the background
LINQ's AsParallel returns ParallelQuery . I wonder if it's possible to change this behavior
I wonder if there is any way I could change the default output (System.out)
I wonder if i change all my regular ForEach to Parallel.ForEach, will speed up
I am writing tests and I wonder if there is a way to change
i wonder if there is a way to change the use audio port for
I wonder how to make image change in my jQuery script smoother. I also

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.