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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:25:12+00:00 2026-06-05T13:25:12+00:00

In ggplot2 version 0.9 the behaviour of the alignment of a plot title changed.

  • 0

In ggplot2 version 0.9 the behaviour of the alignment of a plot title changed. Whereas in v0.8.9 the alignment was relative to the plot window, in v0.9 the alignment is relative to the plotting grid.

Now, whereas I mostly agree that this is desirable behaviour, I quite often have very long plot titles.

Question: Is there a way of aligning the plot title with the plot window rather than the plot grid?

I’m looking for an solution that does automatic alignment of the plot. In other words, manual alignment using hjust would not work for me (I run this on hundreds of plots for each project).

Any solution that used grid directly is also acceptable.


Some sample code and plot: (Notice how the title gets truncated at the right of window).

dat <- data.frame(
  text = c(
    "It made me feel very positive to brand X", 
    "It was clear and easy to understand",
    "I didn't like it al all"),
  value=runif(3)
)
library(ggplot2)
ggplot(dat, aes(text, value)) + 
  geom_bar(stat="identity") +
  coord_flip() +
  opts(title="Thinking about the ad that you've just seen, do you agree with the following statements? I agree that...") +
  theme_bw(16)

enter image description here

  • 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-05T13:25:13+00:00Added an answer on June 5, 2026 at 1:25 pm

    In ggplot2 0.9 you can easily change the layout.

    p <- ggplot(dat, aes(text, value)) + 
      geom_bar(stat="identity") +
      coord_flip() +
      opts(title="Thinking about the ad that you've just seen,\ndo you agree with the following statements?\nI agree that...") +
      theme_bw(16)
    
    gt <- ggplot_gtable(ggplot_build(p))
    gt$layout[which(gt$layout$name == "title"), c("l", "r")] <- c(1, max(gt$layout$r))
    grid::grid.draw(gt)
    

    Perhaps, in the future version, ggplot2 will provide consistent interfaces for tweaking the layout.

    enter image description here

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

Sidebar

Related Questions

library(ggplot2) my_title = This is a really long title of a plot that I
I recently upgraded to ggplot2 0.9.0 from version 0.8.9, and now I'm getting that
library(ggplot2) This code produces a nice looking plot: qplot(cty, hwy, data = mpg, colour
I am using ggplot2 to plot a figure that contains nine facets. Each facet
In Hadley Wickham's ggplot2 book in chapter 10.3, he alludes to making plot functions.
How can I move a ggplot2 legend to the bottom of the plot and
From the documentation for ggplot2's geom_tile() function, we have the following simple plot: #
I am using ggplot2 (respectively qplot) to generate a report with Sweave. Now I
Here's a plot: library(ggplot2) ggplot(mtcars, aes(x = factor(cyl), y = hp, group = factor(am),
I'm trying to create a ggplot2 plot with the legend beneath the plot. The

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.