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

How to cancel/NULLify a title? #198

Closed
MatthieuStigler opened this issue Jul 2, 2020 · 2 comments
Closed

How to cancel/NULLify a title? #198

MatthieuStigler opened this issue Jul 2, 2020 · 2 comments
Labels
feature a feature request or enhancement

Comments

@MatthieuStigler
Copy link

Hi

It seems that if a main title has been added with plot_annotation(title), it is not possible to remove it/NULLify it ex-post? This is possible with ggplot2 with ggtitle(NULL), and very useful (say keep for analysis plots with title yet remove titles for publication, as title will be included in the text software?), is it possible to do with patchwork too?

Thanks!

library(ggplot2)
library(patchwork)
packageVersion("patchwork")
#> [1] '1.0.1.9000'

p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp)) + ggtitle("Some Tiltle")
p2 <- ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear))

## Standrad ggplot allows to NULLify a title
p1 + ggtitle(NULL)

# But not possible with patchwork?
p3 <- p1 + p2 + plot_annotation('This is a title I want to remove ex-post', caption = 'made with patchwork')
p3 + plot_annotation(title=NULL)

Created on 2020-07-01 by the reprex package (v0.3.0)

@Ning-L
Copy link

Ning-L commented Sep 21, 2022

Hi, I just found an alternative way to remove the title added in plot_annotation (PS: I'm not using the same patchwork version, but I think it should work for version 1.0.1)

library(ggplot2)
library(patchwork)
packageVersion("patchwork")
#> [1] '1.1.1'

p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp)) + ggtitle("Some Tiltle")
p2 <- ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear))

p3 <- p1 + p2 + plot_annotation('This is a title I want to remove ex-post', caption = 'made with patchwork')
p3$patches$annotation$title <- NULL
p3

Created on 2022-09-21 with reprex v2.0.2

@MatthieuStigler
Copy link
Author

thanks a lot @Ning-L !!

Hopefully, the maintainers might be able to make this as a feature of the package though!? :-)

@thomasp85 thomasp85 added the feature a feature request or enhancement label Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants