0

In this code,

library(ggplot2)
df <- data.frame(A = c(1,2,3), B=as.factor(LETTERS[1:3]))

p1 <- ggplot(df, aes(B, A)) +
  geom_bar(stat="identity") +
  xlab("")

p1

p1 + theme(axis.text.x=element_text(size=12, face="italic", hjust=0, vjust=0.5)) 

labels <- c(expression(A),
            expression(B),
            expression(C))

p1 +  scale_x_discrete(labels=labels) 

the face="italic" (or "bold", also angle=), argument is ignored, once i changed the labels to expressions. I have to use expressions because of super- and subscripts. Can i specify the theme arguments somewhere else?

nouse
  • 3,315
  • 2
  • 29
  • 56
  • 1
    see http://stackoverflow.com/questions/8281897/ggplot2-font-style-in-label-expression – bVa Mar 20 '17 at 14:35
  • That is solving the fontface-problems. Any idea about the "angle=" argument? – nouse Mar 20 '17 at 14:46
  • 1
    put `theme(axis.text.x = element_text(angle = 90))` after `scale_x_discrete(labels=labels)` – bVa Mar 20 '17 at 14:50

0 Answers0