如何不显示ggplot轴上的所有标签? [英] How to not show all labels on ggplot axis?

查看:2294
本文介绍了如何不显示ggplot轴上的所有标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用 ggplot2 来描绘这个:

那么我怎样才能在X轴上显示每10年的价值?例如?

这是我的命令:



ggplot(prova,aes(x = year,y = mass..g。))+ geom_line(aes(group = 1))

解决方案

列数字?您可以使用 breaks 参数添加 scale_x_continuous 来指定x轴刻度的位置。我不知道图像中年份的范围是什么,但是如果是从1900年到2000年(例如),您可以这样做:

  ggplot(prova,aes(x = year,y = mass..g。))+ 
geom_line(aes(group = 1))+
scale_x_continuous(breaks = seq 1900,2000,10))


I'm trying to using ggplot2 to plot this: But as you can see on the x axis you can't read anything...

So how can I show on the x axis the value every 10 years, for example?

This is my command:

ggplot(prova, aes(x=year, y=mass..g.)) + geom_line(aes(group = 1))

解决方案

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆