如何在ggplot2中使x和y轴与突出的刻度线之间产生间隙 [英] How to make gap between x and y axis and protruded ticks in ggplot2
本文介绍了如何在ggplot2中使x和y轴与突出的刻度线之间产生间隙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建以下样式的图形:
How can I create the following style of graph:
请注意x-y轴(红色圆圈)和x-y轴上的突出刻度线(箭头)之间的间隙.
Notice the gap between x-y axis (red circle) and protruded ticks in x-y axis (arrow).
现在我最多只能做的事情:
At best I can do is this now:
library(ggplot2)
p <- ggplot(mpg, aes(class, hwy)) +
geom_boxplot() +
theme_bw(base_size=10)
p
推荐答案
您可以使用提供geom_rangeframe
和theme_tufte
的ggthemes
来实现类似的目的.
You can achieve something similar using ggthemes
which provides geom_rangeframe
and theme_tufte
.
library(ggplot2)
library(ggthemes)
ggplot(mpg, aes(class, hwy)) +
geom_boxplot() +
geom_rangeframe() +
theme_tufte() +
theme(axis.ticks.length = unit(7, "pt"))
这篇关于如何在ggplot2中使x和y轴与突出的刻度线之间产生间隙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文