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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:28:33+00:00 2026-06-03T02:28:33+00:00

It seems there is some padding around the title, which I can’t figure out

  • 0

It seems there is some padding around the title, which I can’t figure out how to change, any thoughts?

xy <- data.frame(x=1:10, y=10:1)
plot <- ggplot(data = xy)+ geom_point(aes(x = x, y =  y))
plot <- plot + opts(plot.background = theme_rect(colour = 'purple', fill = 'pink', size = 3, linetype='dashed'))
plot
plot + opts(title = 'Graph Title')
plot

If you run this, hold a piece of paper on your screen (old school, I know) in line with the top of the G and T from the title, then run the plot again, you’ll see you have some grey above your paper. Which I can only presume is indicative of some padding around the title? Or likewise, if you run it without the title and hold the paper (above) in line with the end of the pink background, then run it with the title, the top of the G and T are below the paper.

Example is essentially from https://github.com/hadley/ggplot2/wiki/Graph-Panel-Attributes

This suggests there is a line height option but it appears to do nothing http://www.inside-r.org/packages/cran/ggplot2/docs/theme_text

  • 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-03T02:28:34+00:00Added an answer on June 3, 2026 at 2:28 am

    So here is a hack:

    p <- plot + opts(title = 'Graph Title')
    p <- ggplot_gtable(ggplot_build(p))
    p$heights[[2]] <- p$heights[[2]]-unit(0.5, "lines")
    grid.draw(p)
    

    This code remove the padding.

    But I’d recommend to send a feature request: https://github.com/hadley/ggplot2/issues?milestone=

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

Sidebar

Related Questions

I am trying to read command lien argument but it seems there is some
My app has a registered shutdown function and it seems there's some issues with
Is there some valid purpose to minifying before compressing? It seems highly unlikely that
There seems to be some debate over refactoring to utilize java generics within my
There seems to be some controversy on whether the number of jobs in GNU
I have a survey on a website, and there seems to be some issues
(see attached jsfiddle, screenshots; running browsers on Ubuntu 11.10) There seems to be some
It seems that flash.text.TextField in Flash has some built-in padding. In particular, my problem
Reading some Verilog code, there seem to be two ways of defining arguments in
i've been playing some time with different builds of my application and there seem

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.