Ecg
Ecg

Reputation: 942

Why is the x-axis text size not getting bigger with axis.text.x in R?

I am trying to increase the font size of the tick numbers of the x-axis, but is not recognised by theme(), why is it? ARe functions overriding each other?

    df <- data.frame('Variable'=c(1,1,2,2,2,3,3,4,4,4,5,6,6,6,7,7,7),
                         'value'=c(10,11,12,14,12,14,16,12,18,21,19,23,24,25,26,27,25))    


ggplot(df, aes(x = Variable, y = value)) +
             geom_jitter(alpha = 0.8, color = "tomato") +      
    theme(axis.text.x = element_text(size = 25,color="black"),
                 axis.text.y = element_text(size = 12,color="black" ))+    
    theme_classic()+ scale_x_continuous(breaks = 1:7)

enter image description here

Upvotes: 0

Views: 63

Answers (1)

A.Chrlt
A.Chrlt

Reputation: 316

Edit : stefan was quicker in the comment section.

Put the theme() after theme_classic()

ggplot(df, aes(x = Variable, y = value)) +
  geom_jitter(alpha = 0.8, color = "tomato") +      
  scale_x_continuous(breaks = 1:7) + 
  theme_classic() +
  theme(axis.text.x = element_text(size = 25,color="pink"),
        axis.text.y = element_text(size = 12,color="black" )) 

enter image description here

Upvotes: 2

Related Questions