如何在 ggplot2 中制作 x 轴和 y 轴之间的间隙以及突出的刻度线 [英] How to make gap between x and y axis and protruded ticks in ggplot2

查看:94
本文介绍了如何在 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

推荐答案

你可以使用 ggthemes 来实现类似的东西,它提供了 geom_rangeframetheme_tufte.

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

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