Change x axis categories to make them vertical

Hi,

I have created a ggplot and there are a number of categories on the x axis. Some have quite long names so they are merging into one another. Is there any way I can change the categories so that they are written vertically?

I have tried these but neither work:

ggplot(data=adm_filtered, aes(x=injury_type, y=number_of_admissions, fill=age_group)) +
geom_bar(stat="identity") + facet_wrap(vars(sex), nrow=4, ncol=2) + (x=injury_type, las=3)

ggplot(data=adm_filtered, aes(x=injury_type, y=number_of_admissions, fill=age_group)) +
geom_bar(stat="identity") + facet_wrap(vars(sex), nrow=4, ncol=2) + ((x=injury_type, angle=45))

Thanks!

You can try adding the following (adjust the angle as desired).

theme(axis.text.x = element_text(angle = 90))

Thank you! It worked!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.