Closed abalvarenga closed 4 years ago
Please have a look at the documentation. You seem to lack a basic understanding of how {ggtext}
works. You need to set the title
and subtitle
theme elements to element_markdown()
, i.e.
library(ggplot2)
library(wesanderson)
library(ggtext)
ggplot(yearling,aes(x = Generation, y= K, group= Gender,
color=Gender, linetype=Gender,shape=Gender ))+
geom_line() +
geom_point() +
scale_color_manual(values=c("firebrick1","turquoise3"))+
scale_linetype_discrete()+
labs(title = "<b>A. Yearling cattle temperament: percentage of known parents per generation</b><br>
<span style = 'font-size:13pt'>The color and shape represent <b><span style = 'color:firebrick1;'>female</span></b> and <b><span style = 'color:turquoise3;'>male</span></b></span>."
, x = "Generations", y = "% of pedigree completeness") +
theme_classic() +
theme(
axis.text.x = element_text(angle = 90, hjust = 1),
title = element_markdown(),
subtitle = element_markdown()
)
I ran in a similar issue with the title, and to help others who would run in the same issue:
The code given by @thomas-neitmann and especially theme(title = element_markdown())
wouldn't work for me, and I eventually figured that contrary to him, I had to use
labs (title ="something in *italics*")+ theme(plot.title = element_markdown())
Hello:
I have using ggtext to edit my ggplot titles. However, today it is not working. No error messages appear, just the command description in the plot.
I.e.
The outcome:![Rplot](https://user-images.githubusercontent.com/47896488/88432474-43096b00-cdca-11ea-8aae-5e6ec00328da.png)
I appreciate your help, Thank you!