I am trying to make the axis labels in ggplot2 bold and size 12. I am using theme(axis.title = element_text(face = "bold", size=12)) to change axis titles and theme(axis.text = element_text(face= "bold", size=12)) to change axix text. However, in 2 geom_plots the text does not become bold or change size. There is no warning message that the function is unused or unrecognized or anything, it just doesn't change the text.
These lines worked perfectly fine in other ggplots I have made but are not working now and I can not figure out why. Below are two examples of code where I have used the element_text function. The only real difference I can discern between the two is that the one that works uses geom_line to build the plot and the one that doesn't work uses geom_bar. Is there anything that is noticeable in the code that is causing one to work and one not?
#this code works, text becomes size 12 and bold
ggplot(spec, aes(x=Frequency)) +
geom_line(aes(y = AT_avg), color = "blue", size=0.75) +
geom_line(aes(y = avg), color="red", size=0.75)+
ylab("Average Amplitude (dB)")+
xlab("Frequency (Hz)")+
theme_bw()+
theme(axis.title = element_text(face="bold", size=12))+
theme(axis.text = element_text(face="bold",size=12))
#this code does not change the size or face of the text
ggplot(count) + geom_bar(aes(x=freq, y=D_count), stat="identity", fill="red") +
scale_x_continuous(limits=c(0,7000)) +
scale_y_continuous(limits=c(0,15))+
xlab("Frequency (Hz)")+
ylab("")+
theme_bw() +
theme(axis.title = element_text(face = "bold", size=12))+
theme(axis.text = element_text(face= "bold", size=12))+
geom_hline(yintercept=2.23, color ="black", size= 1)
sample data set of count (from code that does not work) included below
> dput(head(count))
structure(list(freq = c(100, 300, 500, 700, 900, 1100), AT_count = c(7,
7, 13, 8, 7, 1), AT_exp = c(3.26, 3.26, 3.26, 3.26, 3.26, 3.26
), D_count = c(4, 5, 9, 4, 2, 2), D_exp = c(2.23, 2.23, 2.23,
2.23, 2.23, 2.23)), row.names = c(NA, -6L), class = c("tbl_df",
"tbl", "data.frame"))