0

I am trying to convert a y-axis of my barplot from exponential to integer. However, the scaling (using scale_y_continuous) won't adjust my plot. u is just a simple dataframe, containing data about people who joined the query. The data frame contains the columns gender, id, zip code and age. Its a dataset with roughly 6500 rows.

I've tried using scale_y_continuous and discrete, it has not worked, though.

p<-ggplot(u, aes(x=gender, y=NROW(gender))) +
  geom_bar(stat="identity", fill="steelblue")+
  theme_minimal()+
  scale_y_discrete(breaks=c(seq(0:6500)))+
  labs(x="Gender",y="Number of Votes")
p
4

1 回答 1

0

You are setting your y values using nrow(). geom_bar has a "count" stat option for this type of plot:

p<-ggplot(u, aes(gender)) +
  geom_bar(stat="count", fill="steelblue")+
  theme_minimal()+
  labs(x="Gender",y="Number of Votes")
p

Hopefully this also fixes your y-axis issue.

于 2019-04-23T11:46:29.043 回答