Aloha,
For the following bar graph:
x <- ggplot(foo, aes(x=variety, y=percent)) + geom_bar()
The following italicizes all of my x-axis text:
x + opts(axis.text.x=theme_text(face='italic'))
However, I would like to italicize only the species names, not the control.
levels(foo$variety)
"control" "species1" "species2" "species3"
Any suggestions?
Example 2: Adding an italic Text to ggplot2 Plot. In this example, firstly we will be creating a data frame of 10 elements and plotting it with the help of ggplot() function in the ggplot2 library. And then with the annotate() function and passing the italic parameter in the fontface, we will add italic text to it.
To rotate x-axis text labels, we use “axis. text. x” as argument to theme() function. And we specify “element_text(angle = 90)” to rotate the x-axis text by an angle 90 degree.
To remove a particular axis title, use element_blank() instead of element_text() , for the corresponding theme argument.
To write text in italic font, use a single underscore or asterix before and after the text. To write text in bold font, use a double asterix or underscores before and after the text.
Try this example:
library(ggplot2)
ggplot(CO2, aes(y=uptake,x=Type, group=Type))+
geom_point()+
scale_x_discrete("Location", labels=expression(Quebec, italic(Mississippi)))
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