【发布时间】:2018-10-11 08:44:56
【问题描述】:
我想为下图中的每个轴创建自定义标签。每个方面都有不同数量的中断。我不想在视觉上计算中断,而是调用一个函数来提供每个方面中断的长度。我知道scales 包中的axTicks 函数为基本R 图提供了这个功能。 ggplots 有什么东西吗?这是我正在使用的实际情节,然后是一些重现类似内容的代码。
require(tidyverse)
require(scales)
vary_1 <- c(
exp(rnorm(250,5,1)),
rnorm(250,10,10),
exp(rnorm(250,20,1)),
exp(rnorm(250,30,1)))
vary_2 <- c(
rep('A',250),
rep('B',250),
rep('C',250),
rep('D',250))
data_frame(vary_1,vary_2) %>%
ggplot(aes(vary_1,color = vary_2,fill = vary_2))+
geom_density()+
facet_wrap(~vary_2,scales = 'free')
axTicks(side = 2)
[1] 0.0 0.2 0.4 0.6 0.8 1.0 # not the correct answer
【问题讨论】: