Is it possible to generate only the title without a plot in ggplot?
ggplot() labs(title = as.character(paste0(paste("title"))),
subtitle = as.character("subtitle"))
I want to drop this grey Rectangle:
CodePudding user response:
You could "remove" the panel background using theme(panel.background = element_blank())
:
library(ggplot2)
ggplot()
labs(
title = "title",
subtitle = "subtitle",
caption = "none"
)
theme(panel.background = element_blank())
EDIT To reduce the white space you could reduce the height when exporting your plot, e.g. in R markdown you could use fig.height
:
---
output: html_document
date: '2022-06-29'
---
```{r fig.height = 1}
library(ggplot2)
ggplot()
labs(
title = "title",
subtitle = "subtitle",
caption = "none"
)
theme(panel.background = element_blank())
```
CodePudding user response:
You can use the theme_void()
for this purpose using the code given below,
ggplot() labs(title = as.character(paste0(paste("title"))),
subtitle = as.character("subtitle"),
caption = "none") theme_void()