So I have my graph made which is really great. I am now just trying to get each x=axis label to be there (patient column).Is there a way for me to do this in ggplot? (please note patient is just 1-67). I have tried a couple of other methods like lars or theme(legend.key.size=unit(1,"in"),legend.title=element_text(size=22),legend.text = element_text(size=17)) axis(1,at=midpts,labels=names(Patient)) but neither have worked. Any advice is appreciated!
ggplot(data=V5.ACE2.double.replacement.and.redo.of.AUC.calculation.CSV.file, mapping=aes(x=Patient,y=Fluorescent.sum.over.240.min,fill=Top.20.),las=2) geom_bar(stat='identity') theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank(),panel.background=element_blank()) labs(x="\nPatient Sample") labs(y="\nFluorescence sum over 240 min") theme(axis.title.x=element_text(size=26)) theme(axis.title.y=element_text(size=26)) theme(axis.text=element_text(size=18)) theme(legend.key.size=unit(1,"in"),legend.title=element_text(size=22),legend.text = element_text(size=17))
CodePudding user response:
Your x-axis is the numeric patient ID and it's getting configured as a continuous scale. It sounds like you want a categorical scale. Turn the Patient column into a factor with something like this:
library(tidyverse)
V5.ACE2.double.replacement.and.redo.of.AUC.calculation.CSV.file <- V5.ACE2.double.replacement.and.redo.of.AUC.calculation.CSV.file %>% mutate(Patient = as_factor(Patient))
And you'll get a categorical axis.