Skip to content

Make plot title position configurable. #3494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 27, 2019

Conversation

clauswilke
Copy link
Member

Closes #3252.

library(ggplot2)

p <- ggplot(mpg, aes(x = class)) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "SUVs are the most popular",
    subtitle = "Number of cars of different classes in the mpg dataset") +
  theme(axis.title.y = element_blank())

p

p + theme(plot.title.position = "plot")

Created on 2019-08-19 by the reprex package (v0.3.0)

@clauswilke
Copy link
Member Author

@thomasp85 Any opinions on this approach? I'm happy to finish this up if there are no major objections.

@thomasp85
Copy link
Member

This is more or less how I was planning to implement it. It will complicate patchwork but that is how it is... enough people have been hacking at ggplot2 to get this.

How does this work with the default tag position?

@clauswilke
Copy link
Member Author

Tag appears to the top left of the plot, which seems reasonable to me. People may have to fiddle a bit with margins around the tag, but it's essentially fine as is.

library(ggplot2)

ggplot(mpg, aes(x = class)) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "SUVs are the most popular",
    subtitle = "Number of cars of different classes in the mpg dataset",
    tag = "A") +
  theme(axis.title.y = element_blank(), plot.title.position = "plot")

Created on 2019-08-24 by the reprex package (v0.3.0)

@thomasp85
Copy link
Member

Yeah, I think this looks fine

@clauswilke clauswilke force-pushed the issue-3252-plot-title-position branch from c2cbecf to 36736bf Compare August 26, 2019 19:13
@clauswilke clauswilke changed the title WIP: Make plot title position configurable. Make plot title position configurable. Aug 26, 2019
@clauswilke clauswilke requested a review from thomasp85 August 26, 2019 22:14
@clauswilke
Copy link
Member Author

I think this is ready for review now.

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but @hadley may have opinions

@hadley
Copy link
Member

hadley commented Aug 27, 2019

LGTM. This is definitely something we should highlight in the release blog post.

@lock
Copy link

lock bot commented Feb 23, 2020

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Feb 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Title default alignment to plot not panel (feature request)
3 participants