ggplot2:没有标签的刻度标记的刻度线较短 [英] ggplot2: Have shorter tick marks for tick marks without labels

查看:111
本文介绍了ggplot2:没有标签的刻度标记的刻度线较短的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用ggplot2的情节,我想在x轴上有许多刻度,但是只有一些刻度会有与它们相关的刻度标签。但是,我希望那些有标签的刻度线比那些没有标签的刻度线更长。

I have a plot using ggplot2 in which I'd like many ticks along the x-axis, yet only some of the ticks will have tick labels associated with them. However, I'd like the tick marks for those that have labels to be longer than those that don't.

推荐答案

你可以通过初始 plot 调用(使用 xaxt ='n')来抑制x轴,然后使用 tcl 来控制标记长度(参见?par )和两个轴(1 ,...)调用。

In base R, you can suppress the x-axis with the initial plot call (with xaxt='n'), and then use tcl to control tick length (see ?par) with two axis(1, ...) calls.

plot(1:10, xaxt='n', ylab='', las=1)
axis(1, at=1:10, tcl=-0.8)
axis(1, at=seq(0, 11, 0.2), labels=NA)

这篇关于ggplot2:没有标签的刻度标记的刻度线较短的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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