Skip to content
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

support title alignment with the plot introduced in ggplot2 3.3.0 #152

Open
IndrajeetPatil opened this issue Apr 15, 2020 · 1 comment
Open

Comments

@IndrajeetPatil
Copy link
Contributor

The latest (3.3.0) release of ggplot2 introduced a way to align the plot titles with the plot:

# setup
set.seed(123)
library(ggplot2)
library(ggExtra)

# basic plot
p <- 
  ggplot(mtcars, aes(wt, mpg)) + geom_point() +
  labs(title = "this title is aligned with the plot and not the axis") + 
  theme(plot.title.position = "plot")

# title aligned with the plot
plot(p)

But this alignment is removed by ggExtra:

# setup
set.seed(123)
library(ggplot2)
library(ggExtra)

# basic plot
p <- 
  ggplot(mtcars, aes(wt, mpg)) + geom_point() +
  labs(title = "this title is aligned with the plot and not the axis") + 
  theme(plot.title.position = "plot")

# alignment removed
ggMarginal(p)

@crew102
Copy link
Contributor

crew102 commented Apr 17, 2020

I'm not sure if this would be all that feasible to support. We pull the title/subtitle grob out of the built scatter plot (see getTitleGrobs()). If the built scatter plot doesn't include modifications to the title/subtitle that come from theme() (e.g., plot.title.position), there wouldn't be an easy way for us to include those modifications. I suppose we could check for modifications such as alignment by inspecting the theme of the built scatter plot and applying those changes to the title/subtitle grob in a piecemeal way (i.e., one by one), but that would be kinda a pain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants