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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:50:33+00:00 2026-05-25T23:50:33+00:00

I wonder how to add facet titles in ggplot2 ggplot(diamonds, aes(cut)) + geom_bar() +

  • 0

I wonder how to add facet titles in ggplot2

ggplot(diamonds, aes(cut)) + geom_bar() +   facet_grid(color ~ clarity)

and change the legend title

ggplot(diamonds, aes(cut, fill=cut)) + geom_bar() +   facet_grid(. ~ clarity)

Thanks for your help.

  • 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-25T23:50:34+00:00Added an answer on May 25, 2026 at 11:50 pm

    The facets are labeled using the levels of the factor used. So if you simply change the levels , such as

    levels(diamonds$clarity) <- letters[1:8]
    

    those facets will now be labeled using those letters. The legend title matches the label for that aesthetic mapping, which you can set via:

    + labs(fill = "Fill legend label")
    

    As an extra tidbit, I’ve noticed that I can set the x and y axis labels to NULL in labs but not the legend titles; for those you use an empty character if you want no title.

    Edit

    Given your clarifications, you can add text outside the plotting area using grid.text:

    print(qplot(1,1),vp = viewport(width = 0.9))
    grid.text(unit(0.95,"npc"),0.5,label = "Right label", rot = 270)
    

    enter image description here

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

Sidebar

Related Questions

I wonder how you can add buttons (left and right) to change page controll
I wonder how to add regression line equation and R^2 on the ggplot .
I just wonder how to add annotation in matlab plot? Here is my code:
I wonder if it's possible to add an Event Listener to a MovieClip that
I wonder about that can I write native SQL to add or delete operations
I wonder if someone can help me. I'm trying to add a reference to
I wonder how to add UI elements programatically to existing nib files. If I
new to vba, and wonder how to address elements within a range. I add
i add share button to my app , what i wonder if there is
I wonder how to add new row/line to textarea while editing that is when

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.