I want to edit the title of my plot so it has four words with only the last ones being bold, example: Title: "This is" (normal font) "my plot" (bold).
I have tried several codes I found online but I only managed to make all of the title for the plot bold.My code (example) is looking something like this as I also want to change thee colour and the position of the title. Right now all of the title is in bold due to "face=bold" in my code. As explained above I would only like the last two words be in bold, yet in one line, so no subtitle or another line below. I am using ggplot2 and help will be greatly appreciated!
plot4 <- plot4 + labs(title = "This is my plot")
plot4 <- plot4 + theme(plot.title=element_text(hjust=0.5, vjust=0.1, face='bold', colour="blue"))
We can make the axis text font bold by using face=”bold” argument to element_text() function.
To change the title font to bold, we can use plot. title argument and specify element_text(face=”bold”) as shown below. And now our plot's title is bold as we wanted. We can also increase the size of the text using size argument inside element_text() in addition to the face=bold argument.
The <b> tag specifies bold text without any extra importance.
Use plotmath
as documented by R documentation and in the ggplot2 wiki.
library(ggplot2)
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) +
geom_point()
p + labs(title = bquote('This is' ~ bold('my plot')))
You can also use the latex2exp
package:
library(ggplot2)
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) +
geom_point()
p + labs(title = latex2exp::TeX("$\\alpha = 5$ text, then \\textbf{bold}"))
or
plot(0, 0, main = latex2exp::TeX("$\\alpha = 5$ text, then \\textbf{bold}"))
with the same effect but more flexibility.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With