当数据不包含负值时,如何使用负x轴值启动ggplot?

时间:2018-07-31 16:42:42

标签: r ggplot2

我在数据中有一些要在绘图上注释的标签。我正在尝试使用directlabels包进行注释。以下是我得到的:

library(directlabels)
ggplot(data =appr_CF_nlc %>% filter(SP_AB_Gp==7), 
       aes(x = frame_index, y = LV_frspacing.m, color = label, group=label)) + geom_line() + 
  geom_dl(aes(label = label), method = list(dl.trans(x = x+.2), "first.points"))  

enter image description here

您会看到标签不完全可见。我怎样才能解决这个问题?我尝试使用scale_x_continuous运气不好:

ggplot(data =appr_CF_nlc %>% filter(SP_AB_Gp==7), 
       aes(x = frame_index, y = LV_frspacing.m, color = label, group=label)) + geom_line() + 
  geom_dl(aes(label = label), method = list(dl.trans(x = x + 0.), "first.points")) +
  scale_x_continuous(expand=c(0.5,0), limits=c(0, 3500))  

enter image description here

0 个答案:

没有答案