Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何使用xlim或ylim停止或排斥重叠点_R_Ggplot2_Ggrepel - Fatal编程技术网

R 如何使用xlim或ylim停止或排斥重叠点

R 如何使用xlim或ylim停止或排斥重叠点,r,ggplot2,ggrepel,R,Ggplot2,Ggrepel,我真的在为可能是一个非常简单的图形而挣扎 对于我的火山图,使用R中的以下代码: > vol+geom_label_repel(data = subset(data, color=="Increased"), aes(label=gene)) 我得到以下图片: 但是,如果我尝试使用xlim将标签限制在右上象限: vol+geom_label_repel(data = subset(data, color=="Increased"), aes(label=gene), xlim = c()

我真的在为可能是一个非常简单的图形而挣扎

对于我的火山图,使用R中的以下代码:

> vol+geom_label_repel(data = subset(data, color=="Increased"), aes(label=gene))
我得到以下图片:

但是,如果我尝试使用xlim将标签限制在右上象限:

vol+geom_label_repel(data = subset(data, color=="Increased"), aes(label=gene), xlim = c())
无论我输入了什么xlim或ylim值,也不管它在代码中的位置,我都会得到以下错误:

Warning: Ignoring unknown parameters: xlim
有人能建议我如何让ggrepel将标签放置在右上方象限中,而不是重叠点吗

sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] bindrcpp_0.2               readr_1.1.1                DESeq2_1.16.1              SummarizedExperiment_1.6.3
 [5] DelayedArray_0.2.7         matrixStats_0.52.2         Biobase_2.36.2             GenomicRanges_1.28.5      
 [9] GenomeInfoDb_1.12.2        IRanges_2.10.3             S4Vectors_0.14.4           BiocGenerics_0.22.0       
[13] ggrepel_0.6.5              dplyr_0.7.3                ggplot2_2.2.1             

loaded via a namespace (and not attached):
 [1] httr_1.3.1              tidyr_0.7.1             viridisLite_0.2.0       bit64_0.9-7            
 [5] jsonlite_1.5            splines_3.4.1           Formula_1.2-2           assertthat_0.2.0       
 [9] latticeExtra_0.6-28     blob_1.1.0              cellranger_1.1.0        GenomeInfoDbData_0.99.0
[13] RSQLite_2.0             backports_1.1.0         lattice_0.20-35         glue_1.1.1             
[17] digest_0.6.12           RColorBrewer_1.1-2      XVector_0.16.0          checkmate_1.8.3        
[21] colorspace_1.3-2        htmltools_0.3.6         Matrix_1.2-11           plyr_1.8.4             
[25] XML_3.98-1.9            pkgconfig_2.0.1         genefilter_1.58.1       zlibbioc_1.22.0        
[29] purrr_0.2.3             xtable_1.8-2            scales_0.5.0            BiocParallel_1.10.1    
[33] htmlTable_1.9           tibble_1.3.4            annotate_1.54.0         nnet_7.3-12            
[37] lazyeval_0.2.0          readxl_1.0.0            survival_2.41-3         magrittr_1.5           
[41] memoise_1.1.0           foreign_0.8-69          tools_3.4.1             data.table_1.10.4      
[45] hms_0.3                 stringr_1.2.0           plotly_4.7.1            munsell_0.4.3          
[49] locfit_1.5-9.1          cluster_2.0.6           AnnotationDbi_1.38.2    compiler_3.4.1         
[53] rlang_0.1.2             grid_3.4.1              RCurl_1.95-4.8          htmlwidgets_0.9        
[57] labeling_0.3            bitops_1.0-6            base64enc_0.1-3         gtable_0.2.0           
[61] DBI_0.7                 R6_2.2.2                gridExtra_2.3           knitr_1.17             
[65] bit_1.1-12              bindr_0.1               Hmisc_4.0-3             stringi_1.1.5          
[69] Rcpp_0.12.12            geneplotter_1.54.0      rpart_4.1-11            acepack_1.4.1 

下面是使用
xlim
ylim
geom\u label\u repel
中的示例:

library(ggplot2)
library(ggrepel)
set.seed(1)
iris2 <- iris[sample(1:nrow(iris), 20),]
ggplot(iris2, aes(x=Sepal.Length,y=Sepal.Width)) +
geom_point() + 
geom_label_repel(aes(label=Species), xlim=c(6,8), ylim=c(3.2,4))
库(ggplot2)
图书馆(ggrepel)
种子(1)

iris2只是一个注释,我在我的数据和尝试中也看到了这一点,该区域中的标签现在确实重叠,这让IMG感到恼火,因为这是ggrepel的点。此外,我上面的exmaple中的标签与点重叠,我再次认为这是ggrepel的点,以避免重叠点或标签?我还没有对这种类型的绘图进行过广泛的测试。有一个弹簧力将文本标签拉向其数据点。我猜当你把标签拉离它们的点这么远的时候,力会变得太大。也许我需要将弹簧力作为一个参数提供给想要削弱它的用户。@Marco,弹簧力参数有什么更新吗?我希望能够将geom_标签_repel放在我图形的特定段中,而不让它们在该段中重叠