Reputation: 63
gg <- ggplot(data = data, aes(Type1Error_v, power_v, color = factor(test))) +
geom_line(alpha = 0.8) +
geom_abline(intercept = 0, slope = 1) +
labs(title = expression(paste(H[0], ": BN with ", mu[1], "=10, ", mu[2], "=11, ", sigma[1]^2, "=1, ", sigma[2]^2, "=50.23, ", rho, "=0.8, ", "N=50, p=10%, t~Exp(0.1)")),
x = "False Positive Rate (Type I Error Rate)",
y = "True Positive Rate (Power)") +
xlim(0, 1)
Is there a way to make the title in two lines? atop and \n both doesn't work here.
Upvotes: 1
Views: 313
Reputation: 50678
An alternative to expression
is to use ggtext
(which requires ggplot >= 3.3.0
); with ggtext
you can format your title using HTML tags.
Here is an example:
library(ggtext)
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
ggtitle("H<sub>0</sub>: BN with μ<sub>1</sub>=10, μ<sub>2</sub>=11; σ<sub>1</sub><sup>2</sup>=1, σ<sub>2</sub><sup>2</sup>=50.23<br>Another line with more text") +
theme(plot.title = element_markdown())
Here <sub>
defines subscript, <sup>
is for superscript, <br>
introduces a line-break, and so on.
Upvotes: 2