This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Changing length of x axis on ggplot

Hi I have made a plot with Chromosomes on x axis and P values on y-axis. On x axis I get all 20 chromosomes that were in the analysis but I want the x axis size to increase to 23 total.

ggplot(Results, aes(x = factor(Chromosomes), y = P-value)) + 
geom_point() + 
theme(axis.text.x = element_text(angle = 90) +  xlab("Chromosome")+ ylab("P-value") +labs(title= 
"Results_analysis" ,y="P-value", x = "Chromosomes")

regards

r ggplot ggplot2

This is not reproducible. Please provide example data, e.g. via dput.

Try making a vector with all the chromosome formatted the way you want, e.g.
all_chroms <- c("chr1", "chr2", "chr3", .. , "chrX", "chrY")

And then use this as the variable levels in factor(), so:

ggplot(Results, aes(x = factor(Chromosome, levels = all_chroms), y = P-value)) .. etc

0 answers

No answers yet.

Log in to answer this question.