norhan abdelaziz
norhan abdelaziz

Reputation: 37

how to set the x axis in the origin order ggplot2

I have a data frame total_likes

total_likes <- data.frame(month = c("June","July","August"),
                          likes =c(24413,28839,35060))

I want to plot month in x axis and likes in y axis. So far I have this code:

ggplot(total_likes, aes(x = month, y = likes , group = 1)) +
  geom_point() +
  geom_line(size = 1.5, colour = "blue") 

with this output was : enter image description here

Two questions axis questions:

  1. Why is the x axis not in the order "June,July,August"? How can I fix it?

  2. Is there a way to make a y axis start from zero not 24000?

Upvotes: 0

Views: 261

Answers (1)

B Williams
B Williams

Reputation: 2050

order your data

total_likes <- data_frame(month = ordered(c("June","July","August"), month.name), 
                          likes =c(24413,28839,35060))

Upvotes: 1

Related Questions