工作,我是新来的R和ggplot2
。我正在与ggplot2
合作,并且我无法让check_overlap=TRUE
对我的geom_text产生任何影响。下面是我的代码示例:Check_overlap不GGPLOT2
require(ggplot2)
LV_plot = ggplot(plotFrame,aes(x=Age,y=fit))
#... plotting other things
my_text = geom_text(data=myDataFrame,mapping=aes(x=Age,y=myDataFrame$firstVolume, label=paste(myDataFrame$firstVolume)),angle=70,size=6,check_overlap=TRUE)
LV_scatterNorm = geom_point(data=myDataFrame,aes(x=Age,y=firstVolume),size=4.0)
LV_lineNorm = geom_line(data=myDataFrame,aes(x=Age,y=firstVolume),size=1.2)
这将创建多个文本元素,但check_overlap = TRUE,对它们的重叠没有影响 - 它们重叠的大部分时间。
这里是我的数据:
myDataFrame:
firstVolume Age
1 26502.54 56
2 28335.54 57
plotFrame:
Age fit se sd
1 43 10481.39 2555.560 16036.31
2 44 11164.03 2390.339 16036.31
3 45 11849.98 2225.044 16036.31
4 46 12537.78 2063.854 16036.31
5 47 13225.95 1910.410 16036.31
6 48 13913.05 1767.397 16036.31
7 49 14597.60 1636.212 16036.31
8 50 15278.15 1516.911 16036.31
9 51 15950.26 1408.477 16036.31
10 52 16612.87 1315.257 16036.31
...etc.
我的结果是这样的:
这是在R 3.1.1中。我究竟做错了什么?
(我试图安装ggrepel但似乎ggrepel是不适用于此版本R的)
谢谢!
您能否提供示例数据和可重复的示例? http://stackoverflow.com/help/mcve –
你确定你使用的是最新版本的ggplot2吗?您的示例适用于我,删除了其中一个标签。 – aosmith
它可能不是最新的,因为我没有使用最新版本的R.是否check_overlap是一个相对较新的功能? – Sarah