Changing length of x axis on ggplot
0
0
Entering edit mode
3.5 years ago
salman_96 ▴ 70

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 • 1.1k views
ADD COMMENT
1
Entering edit mode

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

ADD REPLY
1
Entering edit mode
ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2488 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6