![](/img/trans.png)
[英]Why does ggplot suddenly change formate of y-axis numbers to exponential?
[英]Change Y-axis from exponential to integer
我试图将我的条形图的y轴从指数转换为整数。 但是,缩放(使用scale_y_continuous)不会调整我的情节。 你只是一个简单的数据框,包含有关加入查询的人的数据。 数据框包含性别,ID,邮政编码和年龄等列。 它是一个大约6500行的数据集。
我尝试过使用scale_y_continuous和discrete,但它没有用。
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
您正在使用nrow()设置y值。 geom_bar对此类情节有一个“count”stat选项:
p<-ggplot(u, aes(gender)) +
geom_bar(stat="count", fill="steelblue")+
theme_minimal()+
labs(x="Gender",y="Number of Votes")
p
希望这也可以解决你的y轴问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.