Reputation: 1339
Please consider the following plot. I have maintained details of structure, packages, etc, as I am not sure what is causing the issue. I am sure this is quite simple, but I am unable to make it work.
require(reshape2)
require(ggplot2)
require(dplyr)
require(tidyr)
#setting up labels -- find out why italics expression isn't working??
Fig.labels<-c(expression(paste(italic("C. ret"), "-0d")),
expression(paste(italic("C. ret"), "-4d")),
expression(paste(italic("C. ret"), "-14d")),
expression(paste(italic("M. pan"), "-4d")),
expression(paste(italic("M. pan"), "-14d")))
A1_0d_ret<-rnorm(1:100,20)
A2_4d_ret<-rnorm(1:100,18)
A3_14d_ret<-rnorm(1:100,30)
A4_4d_pan<-rnorm(1:100,7)
A5_14d_pan<-rnorm(1:100,40)
data<-data.frame(A1_0d_ret,
A2_4d_ret,
A3_14d_ret,
A4_4d_pan,
A5_14d_pan)
long.data<-melt(data)
long.data_<-separate(data = long.data, col = variable, into = c("group", "treatment", "species"), sep = "_", remove=FALSE)
ggplot(long.data_, aes(x=treatment, y=log(value), group=variable))+
geom_boxplot(outlier.shape = NA, width=0.2 )+
scale_x_discrete("Never mind weird plot", labels=Fig.labels)+
theme_classic()
I wish to mix normal fonts with italics. Why aren't italics working on the labels from expression()? I have seen so many similar working examples.
Edit: this is on RStudio 1.1.456
Upvotes: 1
Views: 1542
Reputation: 2956
Since your code seems fine by some users, as seen in this created plot by your code (mention that the first tick is normal font for visualization purpose) you can try update your packages
updating single packages
for the librarys like ggplot2 you can use the update.packages()
function (documentation)
updating r
for this answer it's more easy to link an old stackoverflow question
You have to download R from the website and install it again manually, sadly there is no option to do this in RStudio. For more help and a more detailed walktrough check out the old post.
Upvotes: 1