Question

I would like to make a ggplot graph with Period on the x-axis like 2010-01, 2010-02 ..., 2014-03

And my code are like followings:

 ggplot(Result, aes(x=factor(Period), y=No_Seats, colour=Airline, group=Airline)) + geom_line()

And the graph is like this: enter image description here

As you can see we can see the period label clearly. I like to make the period a vertical label. Thanks!

Was it helpful?

Solution

add

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

OTHER TIPS

You could use the scales library and provided x-axis is a date you can use something like

scale_x_date(breaks=Dbreaks,labels=date_format("%Y"))

Where Dbreaks is your specified breaks (most be date breaks otherwise it won't work) and format how you would want it to be printed. With the same library you can specify your breaks. For example

Dbreaks <- seq(as.Date("2006-06-01"),as.Date("2013-06-1"),by='1 year').

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top