如何不在ggplot轴上显示所有标签? [英] How to not show all labels on ggplot axis?
本文介绍了如何不在ggplot轴上显示所有标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 ggplot2
来绘制此图:但是正如您在 x 轴上看到的那样,您无法读取任何内容...
I'm trying to using ggplot2
to plot this: But as you can see on the x axis you can't read anything...
例如,如何在 x 轴上显示每 10 年的值?
So how can I show on the x axis the value every 10 years, for example?
这是我的命令:
ggplot(prova, aes(x=year, y=mass..g.)) + geom_line(aes(group = 1))
推荐答案
您的 year
列是数字吗?您可以添加带有 breaks
参数的 scale_x_continuous
来指定 x 轴刻度的位置.我不知道图像中的年份范围是多少,但如果是从 1900 年到 2000 年(例如),您可以执行以下操作:
Is your year
column numeric? You can add scale_x_continuous
with a breaks
argument to specify where the x axis ticks should be. I can't tell what the range of years is in the image, but if it's from 1900 to 2000 (e.g.) you can do something like this:
ggplot(prova, aes(x=year, y=mass..g.)) +
geom_line(aes(group=1)) +
scale_x_continuous(breaks=seq(1900, 2000, 10))
这篇关于如何不在ggplot轴上显示所有标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文