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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:09:34+00:00 2026-05-13T21:09:34+00:00

At the end of a ggplot, this works fine: + opts(title = expression(Chart chart_title…))

  • 0

At the end of a ggplot, this works fine:

+ opts(title = expression("Chart chart_title..."))

But this does not:

chart_title = "foo"
+ opts(title = expression(chart_title))

nor this:

chart_title = "foo"
+ opts(title = chart_title)

How can I add a title to a ggplot when the title is a variable name?

  • 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-13T21:09:35+00:00Added an answer on May 13, 2026 at 9:09 pm

    As others pointed out, your example seems to work fine for the cases where the variable chart_title is a string or an expression. Sometimes it’s tricky to construct the title variable; for instance, a confusing scenario might arise if chart_title uses some other variables, and if in addition you are using some greek characters so a simple paste(...) doesn’t suffice. To construct a title like that, you could use something like the following:

    foo <- rnorm(100)
    number <- 1
    chart_title <- substitute(paste("Chart no. ",number,": ",alpha," vs ",beta,sep=""), list(number = number))
    qplot(foo,foo) + opts(title = chart_title)
    

    Another function that comes in handy when constructing titles is bquote(). Programmatic title construction can be a messy business; R FAQ 7.13 (http://cran.r-project.org/doc/FAQ/R-FAQ.html) can get you started, but even that FAQ basically tells you to search R-Help when in doubt.

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

Sidebar

Related Questions

What does : at the end of the expression mean? <? if(!validateName($_POST['name'])): ?>
The end goal for this post is to override the ToString() method of a
The end of git status looks like this: # Untracked files: # (use git
the end-result i'm trying to render: <input type=radio name=options id=options_1 />$1 - A Not
At the end of this code: UIViewController *viewController = [[UIViewController alloc] init]; UINavigationController *navigationController
I want to end up with: Hello there! <image> This is an image Hi!
What would be end of source in this case when getting a string input
On the other end of the spectrum, I would be happy if I could
All front-end developers know the pain of coding for Firefox, then viewing our then
I'm a front-end developer and I was looking for opinions about the best all-round

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.