I am using ggplot2. I have species names in my legend and axis title. I found a way to italicize the an entire group: theme(legend.position="right", axis.text.y = element_text(face = "italic")) but I need to know how to pick and choose which words to italicize. For example, the axis title needs to be Carollia Species and the legend title Piper Species. Any suggestions?
> head(pie2)
bat piper prop
1 C. castanea P. scintillans 0.51215992
2 C. perspicillata P. scintillans 0.47720417
3 C. sowelli P. scintillans 0.61759343
4 C. castanea P. reticulatum 0.08928571
5 C. perspicillata P. reticulatum 0.04177665
6 C. sowelli P. reticulatum 0.02287988
pie2 %>%
mutate(piper = factor(piper, levels = unique(pie2$piper))) %>%
ggplot(aes(x=bat, y=prop, fill = piper)) +
geom_bar(stat = 'identity', position = 'stack') +
theme_minimal() +
theme(legend.position="bottom")+
scale_fill_brewer(palette=3, direction = -1)+
coord_flip()+
labs(y='Proportion in Diet', x='Carollia Species')+
guides(fill=guide_legend(title="Piper Species"))+
theme(legend.position="right", axis.text.y = element_text(face = "italic"))