Thanks to visit codestin.com
Credit goes to github.com

Skip to content

modifying start_cap and end_cap for circle sizes #68

@zkamvar

Description

@zkamvar

Hello,

I was wondering if we could use the same logic in label_rect() for circles specifically so we can plot a graph where the edges end on the outer part of the circle.

My question is: how can we specify the variable for the circles? I tried it using the simple data in the edges vignette, but to no avail:

cat("Reproducible example with package reprex version", as.character(packageVersion("reprex")))
#> Reproducible example with package reprex version 0.1.1
library("ggraph")
#> Loading required package: ggplot2
library("igraph")
#> 
#> Attaching package: 'igraph'
#> The following objects are masked from 'package:stats':
#> 
#>     decompose, spectrum
#> The following object is masked from 'package:base':
#> 
#>     union
simple <- make_graph("bull")
# Random names - I swear
V(simple)$name <- c("Thomas", "Bob", "Hadley", "Winston", "Baptiste")
E(simple)$type <- sample(c("friend", "foe"), 5, TRUE)
simp <- create_layout(simple, layout = "graphopt")
set.seed(20170331)
simp$size <- sample(10, 5)
ggraph(simp) + 
  geom_node_circle(aes(r = size)) + 
  geom_edge_link(aes(start_cap = circle(node1.size), 
                     end_cap = circle(node2.size)), 
                     arrow = arrow(length = unit(4, "mm"))) + 
  geom_node_text(aes(label = name))

Session info
devtools::session_info()
#> Session info --------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.3.3 (2017-03-06)
#>  system   x86_64, darwin13.4.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  tz       America/Chicago             
#>  date     2017-03-31
#> Packages ------------------------------------------------------------------
#>  package    * version    date       source                            
#>  assertthat   0.1        2013-12-06 CRAN (R 3.2.0)                    
#>  backports    1.0.5      2017-01-18 CRAN (R 3.3.2)                    
#>  bitops       1.0-6      2013-08-17 CRAN (R 3.2.0)                    
#>  colorspace   1.3-2      2016-12-14 CRAN (R 3.3.2)                    
#>  DBI          0.5-1      2016-09-10 CRAN (R 3.3.0)                    
#>  devtools     1.12.0     2016-06-24 CRAN (R 3.3.0)                    
#>  digest       0.6.12     2017-01-27 CRAN (R 3.3.2)                    
#>  dplyr        0.5.0      2016-06-24 CRAN (R 3.3.0)                    
#>  evaluate     0.10       2016-10-11 cran (@0.10)                      
#>  formatR      1.4        2016-05-09 CRAN (R 3.3.0)                    
#>  ggforce      0.1.1      2016-11-28 CRAN (R 3.3.2)                    
#>  ggplot2    * 2.2.1      2016-12-30 CRAN (R 3.3.2)                    
#>  ggraph     * 1.0.0      2017-02-24 CRAN (R 3.3.2)                    
#>  ggrepel      0.6.5      2016-11-24 CRAN (R 3.3.2)                    
#>  gridExtra    2.2.1      2016-02-29 CRAN (R 3.2.4)                    
#>  gtable       0.2.0      2016-02-26 CRAN (R 3.2.3)                    
#>  htmltools    0.3.5      2016-03-21 CRAN (R 3.2.4)                    
#>  igraph     * 1.0.1      2015-06-26 CRAN (R 3.2.0)                    
#>  knitr        1.15.16    2017-03-29 Github (yihui/knitr@9f6a1c2)      
#>  labeling     0.3        2014-08-23 CRAN (R 3.2.0)                    
#>  lazyeval     0.2.0.9000 2016-07-01 Github (hadley/lazyeval@c155c3d)  
#>  magrittr     1.5        2014-11-22 CRAN (R 3.2.0)                    
#>  MASS         7.3-45     2015-11-10 CRAN (R 3.2.2)                    
#>  memoise      1.0.0      2016-01-29 CRAN (R 3.2.3)                    
#>  munsell      0.4.3      2016-02-13 CRAN (R 3.2.3)                    
#>  plyr         1.8.4      2016-06-08 CRAN (R 3.3.0)                    
#>  R6           2.2.0      2016-10-05 cran (@2.2.0)                     
#>  Rcpp         0.12.9     2017-01-14 CRAN (R 3.3.2)                    
#>  RCurl        1.95-4.8   2016-03-01 CRAN (R 3.2.4)                    
#>  rmarkdown    1.4.0.9000 2017-03-29 Github (rstudio/rmarkdown@7ca7fd7)
#>  rprojroot    1.2        2017-01-16 CRAN (R 3.3.2)                    
#>  scales       0.4.1      2016-11-09 CRAN (R 3.3.2)                    
#>  stringi      1.1.2      2016-10-01 CRAN (R 3.3.0)                    
#>  stringr      1.2.0      2017-02-18 cran (@1.2.0)                     
#>  tibble       1.2        2016-08-26 cran (@1.2)                       
#>  tweenr       0.1.5      2016-10-10 CRAN (R 3.3.0)                    
#>  udunits2     0.13       2016-11-17 CRAN (R 3.3.2)                    
#>  units        0.4-2      2017-01-13 CRAN (R 3.3.2)                    
#>  viridis      0.3.4      2016-03-12 CRAN (R 3.3.0)                    
#>  withr        1.0.2      2016-06-20 cran (@1.0.2)                     
#>  XML          3.98-1.5   2016-11-10 CRAN (R 3.3.2)                    
#>  yaml         2.1.14     2016-11-12 cran (@2.1.14)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions